PIC18F1230 register loading

Status
Not open for further replies.

eem2am

Banned
Joined
Jun 22, 2008
Messages
1,179
Helped
37
Reputation
74
Reaction score
24
Trophy points
1,318
Activity points
0
Hello,

i am using PIC18F1230 and C18 C compiler.

I wish to load an unsigned int (16 bit) into the two 8 bit registers which represent the duty cycle value (PDC0H & PDC0L).

Do readers know how i can do this, which statement i can use?

most grateful for replies
 

The following code should work.

Code:
unsigned int duty_cycle;

PDC0H = (unsigned char)(duty_cycle >> 8);
PDC0L = (unsigned char)(duty_cycle & 0x00ff);
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…