News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Eddy <-- Atmega16 UART communication

Started by WeakDude, April 04, 2012, 08:54:38 PM

Previous topic - Next topic

WeakDude

Hello,

Last topic started to drift apart from interrupts problem so I decided to create new one.

I'm trying to communicate Eddy and Atmega16 with UART.  Everything is ok when it comes to Atmega16:

#define F_CPU         1000000L
#define BAUD         9600
#define MYUBRR ((F_CPU/(BAUD*16UL))-1)

int main(void)
{
        DDRD  = 0xFF;
InitUSART();

        while (1)
        {
            TransmitCharUSART(A);
            _delay_ms(10);
        }
}

void InitUSART(void)
{
UBRRL = MYUBRR;
UBRRH = (MYUBRR >> 8);

UCSRB |= (1 << RXEN) | (1 << TXEN);
UCSRC |= (1 << URSEL) | (1 << USBS) | (3 << UCSZ0); //8 data bits, 2 stop bits
}

void TransmitCharUSART(char cData)
{
while(!(UCSRA & (1 << UDRE))) {};

UDR = cData;
}


But there is something wrong with Eddy:

int main(int argc, char *argv[])
{
int portHandle = SB_OpenSerial(1);      // 1*
SB_InitSerial(portHandle, 6, 0x07, 0);   // 9600, 8 data bits, 2 stop bits, no flow control

char *received;

while(1)
{
SB_ReadSerial(portHandle, received, 8, 0);

SB_LogMsgPrint("%c", received);
SB_LogMsgPrint("\n");
SB_msleep(1000);
}




1* I am not sure which port use. On my board there are RS422 and RS485 interfaces, both using differential data inputs.

On 16-pin header connector, there is RXD pin - should I connect this pin directly with MCU TXD pin?

Best Regards,
Mark

Horsa

#1
Quote from: WeakDude on April 04, 2012, 08:54:38 PM
1* I am not sure which port use. On my board there are RS422 and RS485 interfaces, both using differential data inputs.

On 16-pin header connector, there is RXD pin - should I connect this pin directly with MCU TXD pin?

Hi Mark,
if I have understood correctly, you are trying to connect the following:

  • Atmel Atmega16 through UART port
  • SystemBase Eddy v2.0 S2M (RS422/RS485 version) trough 10-pin or 16-pin header connector

An HW solution could be bridging the level converter on the S2M board and connecting the S2M microcontroller UART directly to your Atmel Atmega16.

If you want to connect Atmega16 UART to RS-422 / RS-485 or RS-232 port (for example J8 Pin 3/4) on Eddy S2M/Pin, then you need a RS-422 or RS-232 Line Driver/Receiver. In this case you can not connect directly.

For simplification, I have added the link to the schematic http://www.trenz-electronic.de/download/d0/SystemBase/d1/Eddy_ARM_modules/d2/Eddy-v2.0/d3/Eddy-S2M-PIN/d4/documents.html.

WeakDude

It's been a long time...

In order to establish communication between Atmega8 and Eddy module I have used MAX485. Sending data from Atmega to Eddy works perfectly fine for me but I would like to implement communication protocol (very simple Modbus).

I am using SB_SendSerial function to send data from Eddy but I can't receive anything on Atmega (RX interrupt).
For now, I am sending only 1 byte every 1s.

I have tried to connect pins TXD and RXD on Atmega directly and interrupt works fine so problem is somewhere else.