How do to a mask using CCS on PIC?

Status
Not open for further replies.

boncker

New Member
Guys,

I need to do a C code (using CCS compiler) in my PIC (16F877A) send to a 7 segment display a number from 0 to 9. I'm using the command output_A(x) (x is the number to send to the display) but this command is for 8 bits. So, this number has until 4 bits (9d=1001b) and the PORTA of the PIC has 8 bits. The bits 0 to 3 I'm using to send the data to the 7 sements display and the bits 4 to 7 I want to use as independent discrete outputs.

Some guys told me that I need to do a mask in the command "output_A(x)" to run correctly. How can I do this mask?

Thanks!
 
Use bitwise operators.

AND the value with 0xF (val & 0xF). To preserve the high bits of the port, read it in, AND out the lower bits and then OR it with the bits you want. (portaval & 0xF0) | (val & 0xF)

there may be a ccs way to do this with their library/intrinsics
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…