| Author |
Message |
|
|
Posted: Apr 13, 2012 - 07:14 PM |
|

Joined: Apr 13, 2012
Posts: 4
|
|
please help me.
Reader Promag GP8.
Data(reader)-->RX(atmega32)-->decode-->LCD
please help me
I speak english very bad.
everyone can write code for me |
|
|
| |
|
|
|
|
|
Posted: Apr 13, 2012 - 07:28 PM |
|


Joined: Mar 27, 2002
Posts: 18599
Location: Lund, Sweden
|
|
|
Quote:
everyone can write code for me
But no-one will. You start and we will help.
I would recommend you do this development in small pieces. Start with the LCD - many people here know how to do that, so you will probably get help. While doing that you will learn a lot, so you will be able to do the other parts more and more on your own.
Start by searching the net (Google) and this site for things like "AVR LCD" and similar. |
|
|
| |
|
|
|
|
|
Posted: Apr 13, 2012 - 07:40 PM |
|


Joined: Feb 19, 2001
Posts: 25923
Location: Wisconsin USA
|
|
|
|
|
|
|
Posted: Apr 14, 2012 - 11:35 AM |
|

Joined: Apr 13, 2012
Posts: 4
|
|
| thanks JohanEkdahl and Superfreak. I will start |
|
|
| |
|
|
|
|
|
Posted: Apr 14, 2012 - 06:44 PM |
|

Joined: Apr 13, 2012
Posts: 4
|
|
|
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <util/delay.h>
#include "myLCD.h"
// Defines
#define BaudRate 9600
//#define UbrrValue ((F_CPU / (16ul * BaudRate)) -1)
#define UbrrValue 51
void loop();
int i = 0;
char ID;
char val = 0;
char code[6];
char checksum = 0;
char bytesread = 0;
char tempbyte = 0;
char USARTReadChar()
{
// Wait until a data is available
while(!(UCSRA & (1<<RXC)))
{
// Do nothing
}
// Now USART has got data
return UDR;
}
void USARTWriteChar(char data)
{
// Wait until transmitter is ready
while(!(UCSRA & (1<<UDRE)))
{
// Do Nothing
}
UDR=data;
}
void USARTInit()
{
// Set Baudrate
UBRRL = UbrrValue;
UBRRH = (UbrrValue>>8);
// Set frame format
// Asynch, 8n1
UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);
// Enable TX/RD
UCSRB = (1<<RXEN) | (1<<TXEN);
}
int main()
{
init_LCD();
clr_LCD();
print_LCD("Tag ID");
USARTInit();
while(1){
loop();
}
}
void loop()
{
val=USARTReadChar();
if(val==2);
bytesread=0;
while(bytesread<12){
val=USARTReadChar();
if((val == 0x0D)||(val == 0x0A)||(val == 0x03)||(val == 0x02)){
break;
}
if ((val >= '0') && (val <= '9')) {
val = val - '0';
}
else if ((val >= 'A') && (val <= 'F')) {
val = 10 + val - 'A';
}
// Every two hex-digits, add byte to code:
if (bytesread & 1 == 1) {
// make some space for this hex-digit by
// shifting the previous hex-digit with 4 bits to the left:
code[bytesread >> 1] = (val | (tempbyte << 4));
if (bytesread >> 1 != 5) { // If we’re at the checksum byte,
checksum ^= code[bytesread >> 1]; // Calculate the checksum… (XOR)
};
}
else
{
tempbyte = val; // Store the first hex digit first…
};
bytesread++; // ready to read next digit
}
if(bytesread==12){
print_LCD("5-byte code: ");
move_LCD(2,1);
for (i=0; i<5; i++) {
print_LCD(code[i]);
}
}
}
my code. LCD not showing up. Can you help me wrong place find. Thanks. |
|
|
| |
|
|
|
|
|
Posted: Apr 18, 2012 - 09:39 AM |
|

Joined: Apr 13, 2012
Posts: 4
|
|
|
|
|
|
|
Posted: Apr 18, 2012 - 10:18 AM |
|

Joined: Aug 21, 2002
Posts: 895
Location: Austria
|
|
Beside not showing your LCD-routines:
Code:
if(val==2);
bytesread=0;
Are you sure with the semikolon at the end of the first line?
BTW, it is very dangerous to place semicolons after closing brakets:
Code:
if (a < b) {
c = 1;
};
else {
c = 2
}
is not valid and will generate an error. |
_________________ /Martin.
|
| |
|
|
|
|
|