How to read RFID tag by ATmega32 using Codevision ?

Status
Not open for further replies.
should I put the first part of the code in interrupt routine?
sth like the following code?
// USART0 Receiver interrupt service routine
interrupt [USART0_RXC] void usart0_rx_isr(void)
{
char status,data;
status=UCSR0A;
data=UDR0;
if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)
{
rx_buffer0[rx_wr_index0]=data;
if (++rx_wr_index0 == RX_BUFFER_SIZE0) rx_wr_index0=0;
if (++rx_counter0 == RX_BUFFER_SIZE0)
{
rx_counter0=0;
rx_buffer_overflow0=1;
};
};
}
 
Last edited:
The first part ( Interrupt Routine ) would be generated by the Automatic Programm Generator.
Let it like it is.

Your parameter is the rx_counter.
You should test this variable in main while(1) loop.
When > 0 a new Byte arrived and You have to do some action -> Readout and process.

E.G. When put in an LCD Output routine into Interrupt, the whole controller is blocked until the output is done.

I'm not shure that You know how it works.

The RX Interrupt get any Byte that was received via USART and save it in a Ring Buffer.

Your Job ist to readout this Buffer, evaluate the data and generate "C" compatible strings.
There are many possible way's to do this.
 
Try this out.
 
Every Timer0 Overflow would called the
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
routine.
In this routine the uc_timeout variable would be incremented by 1.

In this section
if(uc_timeout>OVERFLOWTIME) //Timeout overflown ?
{
uc_timeout=0; //Yes! Reset Timeout
datapoint=0; //Reset data pointer
}
}
else //Else waiting for new tag
{
uc_timeout=0; //Reset Timeout
}

the uc_timeout variable would be testet with an overflow value - In this case 15, that give You ~0,5s timeout at 8MHz clock and the current setting of timer0.
If the variable is bigger than this, the datapointer will be set to 0 and so all the saved Bytes will be thrown away.

In the other case a new byte was received, the overflow since the last byte was not achieved and the timeout variable would be set to 0 until the next byte arrives.

You could check this out with the simulator of AVR Studio 7.

Codevision has no integrated simulator.
The exchange File between this 2 solutions is the .cof File.
 
I got the tag number by gets(code,11) and when i'm trying to show it on LCD one extra character appears on (0,0) on the LCD, how can cut the desired number (just the digits written on the tag?
 
Hello, I'm here again..finally I made the code for showing rfid tag's number on lcd but I don't know how to compare it with a given number
I would suggest You to insert a learn routine into the Controller.
You'll bring the controller into a "learn mode" by pressing a Button or else method.
Then hold the new card on the reader.
The Controller read the string and store it into an EEPROM place, to make it save at power down.

In normal Mode the entire card code will be compared with the stored one's.

Old Cards can be removed manually, when defect manually by an own routine.
The Codes behind this card should be sortet new, to use the EEPROM space effective.
 
let me explain my problem clearly
 
the 10 digits are my numbers but the first character is extra and I don't know what it is, tried to delete it but didn't work
 
the 10 digits are my numbers but the first character is extra and I don't know what it is, tried to delete it but didn't work
I think the fail ist a wrong setting of the Jumper 2 and 3 of the RF01D.
When SW 3 set to 1 the RF01D send a start Byte ( 0x02 ).
The Display interpret's that as character and display this.
Set this pin to 0 should solve that problem.

You also can eliminate that by change the first character into an other byte of ASCII code e.g. 0x20 for a space.

Or copy the String into an other without the first byte.
The length of a string You can get with the command strlen.
So copy the String from byte 1 to the end to byte 0 to an another string.

You see many way's to solve that.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…