Microcontroller › AVR › copying rfid tag no in an array for comparision › hello ljajay… in
hello ljajay…
in ISR
1)
PORTA=0x01;
LED=(1<<PA0);
both are same statments according to your program… why you writing the same statment twice??
2)
similarly you have done for PORTA=0x02 and LED=(1<<PA1);
3)
when you want to turn off your LED you wrote
PORTA=0x02;
LED=(0<<PA1);
the first statment says you want to send a high signal on 1st pin of PORTA {PORTA=0x02} and the nest statment itself you turned it off {LED=(0<<PA1);}
4)
i think you are bit confuse between PORTx and DDRx…
PORTx is used to send the value on that port named “x”.
and DDRx is used to set the direction of that port.
refer to the link for more information about PORT and DDR syntax..
http://www.engineersgarage.com/embedded/avr-microcontroller-projects/led-interface-circuit
5)
in starting of ISR u had done i++ mean the incoming byte will go to next array block..and you havn’t delcared the varialbe i any where in your code.
let me make it more clear..
i must be global variable according to your code
when you started the program the value of i will be zero but as soon you enter the ISR the value of variable i is incremented by one so here i becomes 1 then i checks all the if and else condition you wrote and at last the UDR value goes to
mybyte=UDR;
and here i=1, not zero;
when i reaches thirteen you are compairing mybyte[0] which doesn’t make any sense…
go through all the points and let me know your progress