Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with bit adressibility (Urgent)

Status
Not open for further replies.

khansaab21

Advanced Member level 4
Joined
Apr 12, 2008
Messages
108
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,298
Activity points
2,214
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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top