rs485 moxa uport problem

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

PeteSCH
Posts: 5
Joined: Wed Jul 01, 2015 3:14 pm

rs485 moxa uport problem

Mon Jul 20, 2015 4:20 pm

Hi there
, i am facing a problem regarding the RS485 interface. I am using a ATSAM4SD32 Xplained PRO Board as well as the seriel to USB converter Uport1250i from MOXA. I am using the console from the EDBG as a debugging console. It is no problem sending data via RS485 to the MCU, but if i want so send something to the RS485 from the MCU i dont receive anything. Here the important parts of my code (UART1 is the EDBG console)



void UART0_Handler(void)
{
if ((RS485_PORT->UART_SR & UART_SR_RXBUFF) == UART_SR_RXBUFF)
{
RS485_PDC->PERIPH_RPR = &uart_receive_buffer1;
RS485_PDC->PERIPH_RCR = RS485_BUFFERSIZE;
RS485_PDC->PERIPH_TPR = &uart_receive_buffer1;
RS485_PDC->PERIPH_TCR = RS485_BUFFERSIZE;
PDC_UART1->PERIPH_TPR = &uart_receive_buffer1;
PDC_UART1->PERIPH_TCR = RS485_BUFFERSIZE;
}}

void init_pdc_rs485(void)
{
RS485_PDC->PERIPH_RPR = &uart_receive_buffer1;
RS485_PDC->PERIPH_RCR = RS485_BUFFERSIZE;
RS485_PDC->PERIPH_TPR = &uart_receive_buffer1;
RS485_PDC->PERIPH_TCR = RS485_BUFFERSIZE;
RS485_PDC->PERIPH_PTCR = (PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN);
RS485_PORT->UART_IER = UART_IER_RXRDY;
NVIC_EnableIRQ(UART0_IRQn);
}
void init_rs485(void)
{
PMC->PMC_PCER0 = 1 << RS485_PORT_ID;
RS485_PORT->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX| UART_CR_RXDIS | UART_CR_TXDIS;
uint32_t clock_div = (MAINCK/RS485_BAUDRATE)/16;
RS485_PORT->UART_BRGR = clock_div;
RS485_PORT->UART_MR = 0;
RS485_PORT->UART_MR |= UART_MR_PAR_NO;
RS485_PORT->UART_MR |= UART_MR_CHMODE_NORMAL;
RS485_PORT->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS;
/* Enable receiver and transmitter */
RS485_PORT->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
}

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 3 guests