Hello.
I'm having issues with the digital Outputs. I’m using Hi Tech C with MPLAB and a PICKIT 3.
I have successfully created a program, reading a Digital input to turn a light on.
The issue is that when activate another digital output when there is already one on it turns it off...
For example I have RA0 = 1, (Delay for a second)... then RA1 = 1, (delay for a second).. it turns the first one off when the second is activated and vice versa, I have looked in the header file and from what I understand the command is meant to read the current portA status and "or" them together so that only the target bit is affected.. For some reason it is reading any activated ports as off..
Each LED works during operation but one after the other... i can rewrite the code and have both on, but re using the RA# for another output resets any that were already on.
I am powering the target board from the PICKIT 3.
here is my code....
I literally have searched everywhere and cannot find a solution...
I'm having issues with the digital Outputs. I’m using Hi Tech C with MPLAB and a PICKIT 3.
I have successfully created a program, reading a Digital input to turn a light on.
The issue is that when activate another digital output when there is already one on it turns it off...
For example I have RA0 = 1, (Delay for a second)... then RA1 = 1, (delay for a second).. it turns the first one off when the second is activated and vice versa, I have looked in the header file and from what I understand the command is meant to read the current portA status and "or" them together so that only the target bit is affected.. For some reason it is reading any activated ports as off..
Each LED works during operation but one after the other... i can rewrite the code and have both on, but re using the RA# for another output resets any that were already on.
I am powering the target board from the PICKIT 3.
here is my code....
Rich (BB code):
#define _LEGACY_HEADERS
#include <HTC.H>
#define _XTAL_FREQ 4000000
__CONFIG(LVPDIS & BORDIS & INTCLK & WDTDIS & PWRTEN);
static void flashit()
{
RA1 = 1;
__delay_ms(1000);
RA2 = 1;
__delay_ms(1000);
}
void main(void)
{
int latch1;
PORTA = 0;
TRISA = 0b11110000;
while(1)
{
if(RB0 == 1)
{
if(latch1 == 1)
{
latch1 = 0;
}
else
{
latch1 = 1;
}
while(RB0 = 1)
{
}
}
if(latch1 == 1)
{
flashit();
}
else
{
PORTA = 0;
}
}
}
Last edited: