This stuff is completely losing me.
but lets start with just the TRISIO register on the 12F675 for now.
As i understand (which is apparently wrong), the TRISIO register sets which pins are for output.
I'm using the PICKit1 so hopefully you know of it.
from the example (state machine) source file, press the button and it rotates through the LEDs. To turn on any of the 8 LEDs on the board, the TRISIO is set to different values for different pairs of LEDs. That's the bit that's confusing me. if all you're doing is output, why not just set TRISIO to b'00000000'? OK, perhaps you need a bit ON (high?) for the input switch, pin 3 i believe.
Instead it is given as....
#define TRIS_D0_D1 B'00001111' ; TRISIO setting for D0 and D1
#define TRIS_D2_D3 B'00101011' ; TRISIO setting for D2 and D3
#define TRIS_D4_D5 B'00011011' ; TRISIO setting for D4 and D5
#define TRIS_D6_D7 B'00111001' ; TRISIO setting for D6 and D7
How does this relate to the GPIO register? Given in the code as ....
#define D0_ON B'00010000' ; D0 LED
#define D1_ON B'00100000' ; D1 LED
#define D2_ON B'00010000' ; D2 LED
#define D3_ON B'00000100' ; D3 LED
#define D4_ON B'00100000' ; D4 LED
#define D5_ON B'00000100' ; D5 LED
#define D6_ON B'00000100' ; D6 LED
#define D7_ON B'00000010' ; D7 LED
that 2nd lot is put in GPIO, which is fine, but why? why is it using the same value for D3, D5, and D6.
Sorry for such basic dumb questions, but this just isn't sinking in yet.
Thanks,
Rob
but lets start with just the TRISIO register on the 12F675 for now.
As i understand (which is apparently wrong), the TRISIO register sets which pins are for output.
I'm using the PICKit1 so hopefully you know of it.
from the example (state machine) source file, press the button and it rotates through the LEDs. To turn on any of the 8 LEDs on the board, the TRISIO is set to different values for different pairs of LEDs. That's the bit that's confusing me. if all you're doing is output, why not just set TRISIO to b'00000000'? OK, perhaps you need a bit ON (high?) for the input switch, pin 3 i believe.
Instead it is given as....
#define TRIS_D0_D1 B'00001111' ; TRISIO setting for D0 and D1
#define TRIS_D2_D3 B'00101011' ; TRISIO setting for D2 and D3
#define TRIS_D4_D5 B'00011011' ; TRISIO setting for D4 and D5
#define TRIS_D6_D7 B'00111001' ; TRISIO setting for D6 and D7
How does this relate to the GPIO register? Given in the code as ....
#define D0_ON B'00010000' ; D0 LED
#define D1_ON B'00100000' ; D1 LED
#define D2_ON B'00010000' ; D2 LED
#define D3_ON B'00000100' ; D3 LED
#define D4_ON B'00100000' ; D4 LED
#define D5_ON B'00000100' ; D5 LED
#define D6_ON B'00000100' ; D6 LED
#define D7_ON B'00000010' ; D7 LED
that 2nd lot is put in GPIO, which is fine, but why? why is it using the same value for D3, D5, and D6.
Sorry for such basic dumb questions, but this just isn't sinking in yet.
Thanks,
Rob