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.

RFID ID20 and atmega16

Status
Not open for further replies.
the problem is not with the string
yes i am getting 4500D8917D71 as the string on hyperterminal and proteus simulation
the problem is that I can display this string successfully on lcd ON SIMULATION(proteus)
but when it comes to hardware it displays like " <garbage character>-<garbage character>-4-5-0-0-<garbage character>-8-9-1
i.e. some characters are garbage
 

Are you using HD44780 or compatible LCD? For what clock did you compile the code? Are you using the same clock in hardware? Can you post your circuit?
 

yes im using a compatible lcd (JHD 162A) .. i am not using external clock.. its atmega16's builtin 1MHz clock.. code is also for 1MHz....
I have posted the complete folder zipped in the above comments which includes my simulation and code which works on simulation... Download the zip file in COMMENT # 11 in this thread please go through it

- - - Updated - - -

Here is the zipped file:
 

Attachments

  • RFID CODE.rar
    91.6 KB · Views: 40

try this
#include <stdlib.h>
volatile uint8_t buffer[2];


and modify the while (1) code as follows

while(1)
{

USART_Rx();
itoa(data,buffer,10);
lcd_data(buffer);
}

hope that helps.
 

would you just reconfirm the syntax you give
I copy pasted it but the compiler give syntax error
" Error: D:\RFID PROJECT\CODE.c(4): missing '(' "
 

you refer an error but where that is happened? on Include , volatile or in the while (1) looP
 

oh sorrry.. forgot... it says the error is on volatile
 

may your compiler does not use the volatile for definition of global variable. Just remove it and try again
 

i removed volatile and wrote it as "uint8_t buffer[2];"
still giving the same error
 

may do not understand the uint8_t definition. Ok use the unsigned int buffer [2];

- - - Updated - - -

if the error still occur try int buffer[2];
 

in both unsigned int buffer[2] or int buffer[2]
following two errors are given

" Error: D:\RFID PROJECT\CODE.c(924): function argument #2 of type 'int [2]' is incompatible with required parameter of type 'unsigned char *' "
at " itoa(data,buffer,10); "
.
.
.
and
.
.
" Error: D:\RFID PROJECT\CODE.c(925): function argument #1 of type 'int [2]' is incompatible with required parameter of type 'unsigned char' "
at " lcd_data(buffer); "
 

on avr freaks they note that some older IAR or winavr compilers does not support the itoa functions. You may have one of those versions.
Here is a source code of itoa function, which may need to adapted to your program. **broken link removed**

- - - Updated - - -

that code are sample from the winavr . The itoa function covert the integers you have to ascill characters so be printable in your LCD. If that code does not work try to send an email to the company which produce the compiler if they have some update or if they had some sample code to do the same work.
char* itoa(int val, int base){

static char buf[32] = {0};

int i = 30;

for(; val && i ; --i, val /= base)

buf = "0123456789abcdef"[val % base];

return &buf[i+1];

}
 

Suggestion:

If you use AVR Studio or avr-gcc, it is much more simpler, and safer, to use <util/setbaud.h> for usart baud rate setting as it can handle the USE_2X bit automatically.

Errors:

F_CPU MUST be defined before including <util/delay.h>, if you don't get any warnings at compile time, then it is defined somewhere else, thus making you delays useless. You can define F_CPU as a symbol so it can be known across the source code.
 
Last edited:


Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top