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.

How to write a code by Codevision to read RFID using USART

Status
Not open for further replies.

MAHYAR239

Junior Member level 2
Joined
Apr 25, 2017
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
157
Hey there , I wanna know how can I use USART to write a code by codevision ( and codewizard) to read an RFID(it's RF01D)
and I have ATmega16/32 for it...How can I use of USART interrupt for it?
How many bytes should be my buffer size?
 

I do not understand how this topic is related to USART, Codevision and ATmega. RFID chip has a driver which normally can work with any interface. For example, most popular MFRC522 supports USART, SPI and I2C. And there are really no difference how to connect to chip with any of them.
 

Hi,

Why don't you do a simpke internet search on your own?

Documents, tutorials, video tutorials....what else do you need?


How many bytes maximum does your RFID device send?

Klaus

of course I've done it but couldn't find what I need...and almost never tried RFID before so I asked for help!
I'm not sure about it but I guess it sends 14 bytes ...10 bytes for tag's serial number and others are headers ,...(it's RF01d if you know its exact amount let me know)

- - - Updated - - -

I do not understand how this topic is related to USART, Codevision and ATmega. RFID chip has a driver which normally can work with any interface. For example, most popular MFRC522 supports USART, SPI and I2C. And there are really no difference how to connect to chip with any of them.

How come it's not related!!!!!
I wanna receive using USART...
and my questions are:
How can I do it?!
guess it sends 14 bytes , what's next?
 

Hi,

of course I've done it but couldn't find what I need
--> tell us exactley what you need. We don´t know where is the problem. You just tell you globally need help.

* Divide your task into smaller tasks: Hardware, interface, protocol, software...
* then divide each task into smaller tasks.
* then try to solve one of these small taks. Not multiple at once. Give sources you found in the internet. Tell us what you don´t understand.

AFTER one task is solved go to the next tast. and process it the same way.

*******
and almost never tried RFID before so I asked for help
What´s the problem with RFID? It just sends some data. Like any other input device. And the UART also is the same.

*****
I'm not sure about it but I guess it sends 14 bytes
We don´t know also. I assume it depends on the RFID slave. Only you have the informaton what RFID slave is "connected", so it´s on you to give us the informations.

****
10 bytes for tag's serial number and others are headers ,...(it's RF01d if you know its exact amount let me know)
Either you or one of us needs to read datasheets for this. If we read it ... then we have to write the contents here in this thread .. and you need to read it from the thread.
Isn´t it better you read the datasheet by yourself?
All we professionals need to read datasheets. A lot of them. And yes - it may be boring - but there´s no way around it.

****
guess it sends 14 bytes , what's next?
Yes. what´s next? How can we know what you want to do with the data?
Display it on a LCDisplay? archivate the data in an internet could? print out a label? Browsing a database and open a door/or not?
Aagin: you have to tell us.

Klaus
 
Hi,


--> tell us exactley what you need. We don´t know where is the problem. You just tell you globally need help.

* Divide your task into smaller tasks: Hardware, interface, protocol, software...
* then divide each task into smaller tasks.
* then try to solve one of these small taks. Not multiple at once. Give sources you found in the internet. Tell us what you don´t understand.

AFTER one task is solved go to the next tast. and process it the same way.

*******

What´s the problem with RFID? It just sends some data. Like any other input device. And the UART also is the same.

*****

We don´t know also. I assume it depends on the RFID slave. Only you have the informaton what RFID slave is "connected", so it´s on you to give us the informations.

****

Either you or one of us needs to read datasheets for this. If we read it ... then we have to write the contents here in this thread .. and you need to read it from the thread.
Isn´t it better you read the datasheet by yourself?
All we professionals need to read datasheets. A lot of them. And yes - it may be boring - but there´s no way around it.

****

Yes. what´s next? How can we know what you want to do with the data?
Display it on a LCDisplay? archivate the data in an internet could? print out a label? Browsing a database and open a door/or not?
Aagin: you have to tell us.

Klaus

Hi again.
--------------------------------
Ok, let me make it more clear.
In first step just guess I wanna read RFID tags and just put them in variable like "tag".
My hardwares : ATmega 32, RF01d , tags
...yes it simply sends data:bang: but how can I receive it?
what changes should I apply in the USART interrupt code that Codewizard generates ?
the following page provides its datasheet but I can't get what I need again
http://www.datasheet39.com/PDF/916937/RF01D-datasheet.html
 

Hi,

It seems you didn't read the first lines of my last post.
You still mix everything up, instead of focus to one single item.

Klaus
 

How come it's not related!!!!!
I wanna receive using USART...
and my questions are:
How can I do it?!
guess it sends 14 bytes , what's next?
This is my library for MFRC522
https://github.com/Virviglaz/MyLibraries/blob/master/Common/MFRC522.c
https://github.com/Virviglaz/MyLibraries/blob/master/Common/MFRC522.h
To make it works you need to assign function:
void (*WriteData)(char reg, char * buf, char size);
void (*ReadData) (char reg, char * buf, char size);
void (*Delay_Func)(uint32_t us);
Which is needed to handle the interface. It can be I2C, SPI or USART. Doesn't matter.
After that you init the chip and will be able to operate it with function MFRC522_Operate32 giving it key calculation function and handler in case of sucessful reading the card. It is pure C code. Will work the same way with any C compilier and basically any kind of hardware. So, my question is still actual.
 
This is my library for MFRC522
https://github.com/Virviglaz/MyLibraries/blob/master/Common/MFRC522.c
https://github.com/Virviglaz/MyLibraries/blob/master/Common/MFRC522.h
To make it works you need to assign function:
void (*WriteData)(char reg, char * buf, char size);
void (*ReadData) (char reg, char * buf, char size);
void (*Delay_Func)(uint32_t us);
Which is needed to handle the interface. It can be I2C, SPI or USART. Doesn't matter.
After that you init the chip and will be able to operate it with function MFRC522_Operate32 giving it key calculation function and handler in case of sucessful reading the card. It is pure C code. Will work the same way with any C compilier and basically any kind of hardware. So, my question is still actual.
Thanks:roll::roll:but I want to learn how to write the code using Codevision ,as I said I enabled USART in Codewizard and wanna know the next step to receive data by my RFID reader....it's "RF01D" by the way.
can you please tell me the next steps?
for example by what function in my USART interrupt I can read the data?
guess it's my code:
/ USART Receiver interrupt service routine
interrupt [USART_RXC] void usart_rx_isr(void)
{
char status,data;
status=UCSRA;
data=UDR;
if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)
{
rx_buffer[rx_wr_index++]=data;
#if RX_BUFFER_SIZE == 256
// special case for receiver buffer size=256
if (++rx_counter == 0) rx_buffer_overflow=1;
#else
if (rx_wr_index == RX_BUFFER_SIZE) rx_wr_index=0;
if (++rx_counter == RX_BUFFER_SIZE)
{
rx_counter=0;
rx_buffer_overflow=1;
}
#endif
}

- - - Updated - - -

This is my library for MFRC522
https://github.com/Virviglaz/MyLibraries/blob/master/Common/MFRC522.c
https://github.com/Virviglaz/MyLibraries/blob/master/Common/MFRC522.h
To make it works you need to assign function:
void (*WriteData)(char reg, char * buf, char size);
void (*ReadData) (char reg, char * buf, char size);
void (*Delay_Func)(uint32_t us);
Which is needed to handle the interface. It can be I2C, SPI or USART. Doesn't matter.
After that you init the chip and will be able to operate it with function MFRC522_Operate32 giving it key calculation function and handler in case of sucessful reading the card. It is pure C code. Will work the same way with any C compilier and basically any kind of hardware. So, my question is still actual.
Thanks:roll::roll:but I want to learn how to write the code using Codevision ,as I said I enabled USART in Codewizard and wanna know the next step to receive data by my RFID reader....it's "RF01D" by the way.
can you please tell me the next steps?
for example by what function in my USART interrupt I can read the data?
guess it's my code:
/ USART Receiver interrupt service routine
interrupt [USART_RXC] void usart_rx_isr(void)
{
char status,data;
status=UCSRA;
data=UDR;
if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)
{
rx_buffer[rx_wr_index++]=data;
#if RX_BUFFER_SIZE == 256
// special case for receiver buffer size=256
if (++rx_counter == 0) rx_buffer_overflow=1;
#else
if (rx_wr_index == RX_BUFFER_SIZE) rx_wr_index=0;
if (++rx_counter == RX_BUFFER_SIZE)
{
rx_counter=0;
rx_buffer_overflow=1;
}
#endif
}

- - - Updated - - -

Hi,

It seems you didn't read the first lines of my last post.
You still mix everything up, instead of focus to one single item.

Klaus
I just asked a single question!
How to receive RF01D data using USART !!!!

then explained what I've done till now : just enabled USART receiver interrupt
that's ok now?:bang:
 

what should I do next?!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top