khansaab21
Advanced Member level 4
Hello every one.
I have written the following program using MikroC for PIC16F628. In the beginning I am defining bits 0-4 of port A using '#define'. On those 4 bits are connected LED's.
THE PROBLEM IS WHEN SERIAL DATA ARRIVES FROM PC, ONLY ONE OF THE LED FLASHES (AND THEN GOES OFF) AS ACCORDING TO THE PATTERN DEFINED IN THE 'IF' CONDITION WHILE THE OTHER REMAINS COMPLETELY OFF THROUGHOUT.
Note: I ONLY have to use the lower 4 bits of port A for this purpose. I guess there is some problem with bit addressibility. But i cant trouble shoot it. Help is required urgently.
SOURCE CODE:
#define A1 PORTA.F0
#define A2 PORTA.F1
#define A3 PORTA.F2
#define A4 PORTA.F3
#define ON 1
#define OFF 0
void main()
{
unsigned char mybyte;
Usart_Init(9600); //Initializing USART
for(;
{
if (Usart_Data_Ready()) //Checking for completeness of data in the buffer
{
mybyte = Usart_Read(); //Reading the buffer
if (mybyte == 0xA3)
{
A1 = ON; //This LED doesnt light at all
A2 = OFF;
A3 = ON; //Only this LED flashes for sec and then goes off
A4 = OFF;
}}}
Urgent help is required plz.
I have written the following program using MikroC for PIC16F628. In the beginning I am defining bits 0-4 of port A using '#define'. On those 4 bits are connected LED's.
THE PROBLEM IS WHEN SERIAL DATA ARRIVES FROM PC, ONLY ONE OF THE LED FLASHES (AND THEN GOES OFF) AS ACCORDING TO THE PATTERN DEFINED IN THE 'IF' CONDITION WHILE THE OTHER REMAINS COMPLETELY OFF THROUGHOUT.
Note: I ONLY have to use the lower 4 bits of port A for this purpose. I guess there is some problem with bit addressibility. But i cant trouble shoot it. Help is required urgently.
SOURCE CODE:
#define A1 PORTA.F0
#define A2 PORTA.F1
#define A3 PORTA.F2
#define A4 PORTA.F3
#define ON 1
#define OFF 0
void main()
{
unsigned char mybyte;
Usart_Init(9600); //Initializing USART
for(;
{
if (Usart_Data_Ready()) //Checking for completeness of data in the buffer
{
mybyte = Usart_Read(); //Reading the buffer
if (mybyte == 0xA3)
{
A1 = ON; //This LED doesnt light at all
A2 = OFF;
A3 = ON; //Only this LED flashes for sec and then goes off
A4 = OFF;
}}}
Urgent help is required plz.