Searching \ for '[PIC]:treating CCPR1L and CCPR1H as an int in PICC' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'treating CCPR1L and CCPR1H as an int in PICC'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:treating CCPR1L and CCPR1H as an int in PICC'
2001\03\29@145324 by Bob Blick

face
flavicon
face
I am using HiTech PICC and want to subtract capture 1 from an integer
value. I know there's a way to specify it in C so that it treats the
sequential registers CCPR1L and CCPR1H as a 16 bit number, but can't put
my finger on it.

I know I could use a temporary integer but that would be wasteful and I
could also do the subtraction in inline assembler but that isn't
neccessary. I hate it when I can't remember how to do stuff like this.

Thanks in advance,

Bob Blick

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\03\29@151155 by Andrew E. Kalman

flavicon
face
>I am using HiTech PICC and want to subtract capture 1 from an integer
>value. I know there's a way to specify it in C so that it treats the
>sequential registers CCPR1L and CCPR1H as a 16 bit number, but can't put
>my finger on it.


Here's how I do TMR1 on a 16C77:

static voltatile unsigned int TMR1 @0xFCE;
--

 ______________________________________
  Andrew E. Kalman, Ph.D.   spam_OUTaekTakeThisOuTspampumpkininc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\03\29@151603 by Dipperstein, Michael

face picon face
> From: Bob Blick [.....bobKILLspamspam@spam@ted.net]
> I am using HiTech PICC and want to subtract capture 1 from an integer
> value. I know there's a way to specify it in C so that it treats the
> sequential registers CCPR1L and CCPR1H as a 16 bit number,
> but can't put
> my finger on it.

The function below uses a pointer and does what you want to do.  I used 31415
for the subtraction just to have value.  Be careful.  16 bit math is not atomic
and CCPR1L and CCPR1H can change while you're working with them, if you're not
configured correctly.

-Mike

int foobar(void)
{
   int *foo;

   foo = &CCPR1L;
   return (31415 - (*foo));
}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\03\29@185123 by Bob Blick

face
flavicon
face
On Thu, 29 Mar 2001, Andrew E. Kalman wrote:
> Here's how I do TMR1 on a 16C77:
>
> static volatile unsigned int TMR1 @0xFCE;

Perfect. Thanks!

-Bob

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\03\29@203105 by Bob Ammerman

picon face
If it is anything like  ANSI C the following should work (no guarantee on
the efficiency of the generated code):

       return 31415 - * (int *) &CCPR1L

To break it out, working right to left:

&CCPR1L returns the address of CCPR1L, presumably an unsigned char

(int *) says to treat that address as a pointer to an int instead of a
pointer to an unsigned char

* says to use the value pointed to be that pointer to an int

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)


{Original Message removed}

2001\03\30@004939 by Bob Blick

face
flavicon
face
Thanks for these good explanations!

-Bob

At 08:22 PM 3/29/2001 -0500, you wrote:
{Quote hidden}

>{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...