View previous topic :: View next topic |
Author |
Message |
ambokyo
Joined: 01 Dec 2010 Posts: 4
|
How to get determine the value of an output port (SOLVED) |
Posted: Wed Dec 01, 2010 9:29 am |
|
|
Assuming PORT B is outputting 0xFF. How can I read the status of PORT B so I could determine the output state?
Sorry for being such a noob in CCSC but CCSC doesn't seem to recognize PORTB keyword.
Last edited by ambokyo on Thu Dec 02, 2010 6:27 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Wed Dec 01, 2010 9:40 am |
|
|
Multiple parts:
If you have just output '0', then you already know what has been output.....
If you are using 'fast_io' mode, then input_b() returns the state of the port.
Input_state returns the state of a pin, without changing the port direction.
Normally the input instruction _will_ set the port as an input automatically.
You can define PORTB as a variable mapped to the output latch, using #byte.
If you have the IDE, then 'tools', 'device editor', 'registers', 'make include file', will automatically build a file with all the registers and bits defined for you.
Best Wishes |
|
|
ambokyo
Joined: 01 Dec 2010 Posts: 4
|
|
Posted: Thu Dec 02, 2010 6:29 am |
|
|
Thanks so much.
#byte and #bit is exactly what I was looking for. |
|
|
|