kyussinchains
New Member
Hi,
I'm a total novice when it comes to embedded programming, I've been playing around with C for years, but never consistently, it seems I have to re-learn it all each time I come around to using it....
I've been given a microchip pickit1 flash starter kit with a pic12f675 onboard and I'm banging my head on a wall trying to make a single LED flash.... I can make two flash at once, but isolating a single one seems beyond me at the moment!
my problem is that the LEDs on the demo board are wired in a tri-state configuration and I don't seem to be able to set the pins in a high Z configuration. I'm using pin 3 to source the current for the LED, pin 2 to sink it, and setting pins 5 and 6 to input mode (High Z I believe)
my code is below:
can anyone suggest why it's switching two LEDs on instead of a single one?
oh and I'm using MPLAB 8.10 and HI-TIDE 9.60
thanks in advance!
I'm a total novice when it comes to embedded programming, I've been playing around with C for years, but never consistently, it seems I have to re-learn it all each time I come around to using it....
I've been given a microchip pickit1 flash starter kit with a pic12f675 onboard and I'm banging my head on a wall trying to make a single LED flash.... I can make two flash at once, but isolating a single one seems beyond me at the moment!
my problem is that the LEDs on the demo board are wired in a tri-state configuration and I don't seem to be able to set the pins in a high Z configuration. I'm using pin 3 to source the current for the LED, pin 2 to sink it, and setting pins 5 and 6 to input mode (High Z I believe)
my code is below:
Code:
#include <htc.h>
__CONFIG(UNPROTECT & BORDIS & MCLRDIS & PWRTEN & WDTDIS & INTIO);
void main()
{
unsigned int i;
TRISIO = 0b000011; //set GPIO0-3 as inputs, high Z
ANSEL = 0x00; //clear ansel register
CMCON = 0x07; //disable comparator
while (1){ //loop continuously
GPIO4 = 1; //set pin 3 high, LED on
GPIO5 = 0; //set pin 2 low
for(i = 0; i < 10000; ++i)
{
// do nothing, busy wait loop
}
GPIO4 = 0; //set pin 3 low, LED off
GPIO5 = 0; //set pin 2 low
for(i = 0; i < 10000; ++i)
{
// do nothing, busy wait loop
}
}
}
can anyone suggest why it's switching two LEDs on instead of a single one?
oh and I'm using MPLAB 8.10 and HI-TIDE 9.60
thanks in advance!