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