Oznog said:
However, I'm a bit confused here. Normally for say an LED you'd put the anode on Vdd, then a resistor between the cathode and a PIC pin. The PIC turns it on when it's pulled low. Rather than turning it off by making it TRIS, you'd simply drive it high. When the pin is high there is 0v on the LED-resistor series string so it's off.
this is a compound device, the package has 1 anode and 3 cathodes ... so I am using 3 bits from the PIC, to control each cathode independently. There are resistors between each pin and the cathodes... so think of it as three leds wired in parallel, with their anodes tied together.
A little more detail ... the blinking is performed by reading the state of another pin... so I have a single bit controlling 3 bits. Forgive my lazyness, but this is the basic code:
Code:
If BlinkOPT = 1 Then
' pass hdd input along to the pin direction registers
TRISIO.0 = HDD
TRISIO.1 = HDD
TRISIO.2 = HDD
Else ' set pin direction as output
TRISIO.0 = 0: TRISIO.1 = 0: TRISIO.2 = 0
EndIf
hdd is an alias (symbol) for gpio3 ... so the code reads 3 and sets 0:2 accordingly... it is an active low signal as well, so I want the rgb to be on when hdd is low, and off when it is high
the problem with changing the output drive I suppose is how my program is laid out... there are several different subs that might get called depending on conditions, all of which change the output drive to the RGB ... so one of them may change the drive, and then the blink routine goes and changes it to something else, which could lead to erratic blink operation
so I thought it would be safe to leave the output alone, and just change the pin direction register instead?
You could also put the LED string from PIC pin to ground so it turns on when the pin is high.
this might be an option in the future, when/if I run out of the leds I have... but for now, these are nice display quality leds, and their internal wiring cannot be changed, at least, not by me.
TRIS is slightly unsafe in that the pin has reduced ESD protection.
not sure I follow you here ... the way I read the diagrams from Microchip, the ESD protection diodes are always in place? I suppose having un-used pins set as high impedance inputs does minimize the chance the pic will have to swallow a surge?
I like to think of it is a novel approach, rather than odd :lol: