Trenz Electronic GmbH Support Forum

Archived Boards and Threads => Archived Boards => Eddy Modules => Topic started by: WeakDude on April 04, 2012, 08:54:38 PM

Title: Eddy <-- Atmega16 UART communication
Post by: WeakDude on April 04, 2012, 08:54:38 PM
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
Title: Re: Eddy <-- Atmega16 UART communication
Post by: Horsa on April 11, 2012, 10:38:58 AM
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:

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 (http://www.trenz-electronic.de/download/d0/SystemBase/d1/Eddy_ARM_modules/d2/Eddy-v2.0/d3/Eddy-S2M-PIN/d4/documents.html).
Title: Re: Eddy <-- Atmega16 UART communication
Post by: WeakDude on December 11, 2012, 11:50:21 PM
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.