Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
thanks for your answer, but I really need more help ...I even don't know how to receive the data from it...I would make the buffer bigger.
I think 40Bytes are OK.
Cause:
You have to readout the buffer before it will be overwritten.
When the buffersize is to small You'll loose data.
It depends how many other tasks your controller has to compute.
delay commands should be avoided.
// USART0 Receiver buffer
#define RX_BUFFER_SIZE0 80
char rx_buffer0[RX_BUFFER_SIZE0];
#if RX_BUFFER_SIZE0<256
unsigned char rx_wr_index0,rx_rd_index0,rx_counter0;
#else
unsigned int rx_wr_index0,rx_rd_index0,rx_counter0;
#endif
// This flag is set on USART0 Receiver buffer overflow
bit rx_buffer_overflow0;
// 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;
};
};
}
// Get a character from the USART0 Receiver buffer
#define _ALTERNATE_GETCHAR_
#pragma used+
char getchar(void)
{
char data;
while (rx_counter0==0);
data=rx_buffer0[rx_rd_index0];
if (++rx_rd_index0 == RX_BUFFER_SIZE0) rx_rd_index0=0;
#asm("cli")
--rx_counter0;
#asm("sei")
return data;
}
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: On
// USART0 Mode: Asynchronous
// USART0 Baud rate: 38400
UCSR0A=0x00;
UCSR0B=0xD8;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x19;
To read out more than one Byte You have to define a Buffer and search for an End Term.//Receive one Byte - This has to be in the Main Loop
while(rx_counter0>0)
{
getchar();
//Receive Sensor Data
}
http://www.datasheet39.com/PDF/916937/RF01D-datasheet.htmlI'm not really shure what a RF01D is.
A 433MHz Receiver or an RFID Card reader.
Do You have any link to a Datasheet?
What about this ? what does it mean by 8/9 data?by which information should I choose among options of this section ?Then choose the comunication parameters.
The Example works with 38400 Bit/s 8,N,1Then choose the comunication parameters.
The receive Routine works interupt driven.while(rx_counter0>0)
So I would prepare the datax variable for 15Bytes ( = 1 complete String + CR/LF + 0 +2 spacer )my tags contains 10 digits on their serial numbers
Where did they come from?When a new byte was received, You had to check it for 0x10 ( = ENTER ).
When the last Byte is 0x10, I would check the byte before it had to be 0x13.
I don't have any idea about them, can you please tell me about them?1 complete String + CR/LF + 0 +2 spacer
one string equals to 12.5 bytes?The interrupt receive buffer can be lower. I think 25Bytes are enough ( 2 complete Strings ).
so I have to do it 15 times? cuz it is 15 bytes?Every Byte You read out with: bytex=getchar();
you mean this one?SW 2 + 3 of the RF01D had to be set to o by switch.
In Your last Post in the field OUTPUT DATA the two last bytes are 0x13 and 0x10.Where did they come from?
You get 10Bytes by the ID and 2Bytes Enter ( =0x13 + 0x10 ).one string equals to 12.5 bytes?
Yes Sir.you mean this one?
This would be in the Initialisation at top of main.ccan it be the main loop?
unsigned char datax[15];
In CodeVision i can't find anything about gets.gets(datax,15);
so this is how the RFID realizes when to finish reading, is there similar method for when to start reading?In Your last Post in the field OUTPUT DATA the two last bytes are 0x13 and 0x10.
you fantastically explained it , I really can't thank you for it.You get 10Bytes by the ID and 2Bytes Enter ( =0x13 + 0x10 ).
To use the string functions of "C" you had to insert a 0 as last Byte.
So You get 13Bytes. The additional 2Bytes are only for safety.
I guess I understand this variable , it saves the 15 bytes RFID sends (correct me if i'm wrong please)unsigned char datax[15]; //Prepare a variable with 15 possible values you use as string
But I don't know what this variable works.unsigned char datapoint=0; //Prepare a variable that used as pointer and set it to 0
what do you mean? what's wrong with that code?What missing now is the trouble shooting.
I really appreciate and never forget your favor!void makestring(void)
{
datax[datapoint]=getchar(); //Get the next character
datapoint++;
if ((datax[datapoint-2] == 0x13) && (datax[datapoint-1] == 0x10)) //End of string is reached?
{
datax[datapoint] = 0x00; //Insert the "C" String end
lcd_puts(*datax); //Any output routine could be insert here LCD, USART or something else.
datapoint = 0; //Set Pointer to 0 for next card
}
//In main loop in the section while(1) You have to insert
while(rx_counter>0)
{
makestring();
//Receive Data and generate a string
}
It adresses the place where the next character placed in the datax string.But I don't know what this variable works.
When an uncomplete string from the RF01D was received the datapoint pointer has the last value.what do you mean? what's wrong with that code?
I guess the RF01D generate a string at it's TX pin, when a ID Card is reachable.so this is how the RFID realizes when to finish reading, is there similar method for when to start reading?