[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] UART Receive Problems
From: |
Daniel Mittag |
Subject: |
[avr-gcc-list] UART Receive Problems |
Date: |
Sat, 3 Mar 2001 01:38:57 +0100 |
Hello,
I have a general problem using the UART of the AT90S2333:
I've written a little test programm (in C) that receives values over the
UART and visualizes them via 6 LED's that are connected to PORTB (PB0-PB5).
(just bit0-5 are displayed as PORTB of the 2333 is only 6 bits wide.
On the pc-side, I've done a output proggy that allows you to enter a value
and send it over COM2.
I't quiet simple, it only sends a value to the COM2 hardware adress,
baudrate, parity and stopbits are defined by windows98 enviroment, not by
the program. I use 9600baud, 8,N,1. (Same on the Atmel side, of course)
The problem is that the Atmel MCU receives a byte but not the one I sent.
The received bytes
seem to be shifted and negated in some way, when I first leftshift and then
negate
( ~(byte<<1)) the byte on the sender side, the atmel displays correct values
but then I just can use values between 0 and 128, 129 will be displayed as 1
and so on.
I'm a AVR newbie, so maybe it's a obvious thing, but I don't get it, please
help!
Thanks in advance!
Daniel Mittag
DMS Dance Music Service
*** the receiver program: (compiled with AVR-GCC) ***
// Testprogramm Atmel AT90S2333
#include <io.h>
#include <signal.h>
#include <interrupt.h>
SIGNAL(SIG_UART_RECV)
{
outp(inp(UDR), PORTB);
}
void main(void)
{
sbi(UCR, RXCIE); //Recieved Complete Interrupt
Enabled
sbi(UCR, RXEN); //Recieved Enabled
outp(51, UBRR); //Baudrate 9600
outp(63, DDRB); //PortB = Output
outp(0, PORTB);
sei(); //Enable Global
Interrupts
while(1){};
}
*** the sender: (compiled with MS Visual C++ 6.0)***
#include <conio.h> //_inp(), _outp()
#include <stdio.h> //Ein-u.Ausgabe (?)
void main(void)
{
int input;
clock_t time;
while(1)
{
scanf("%d", &input);
printf("\nEingelesen: %d\n", input);
_outp(0x2F8, input); // <- ~(input<<1)!!
}
}
- [avr-gcc-list] UART Receive Problems,
Daniel Mittag <=