SAME70 RS485, 9 bit Address Mode

Go To Last Post
2 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a custom board using the SAME70Q21 uC, that I have configured using the atmel START utility.


I have configured UART2 in the following way:

9 bit character mode has been selected, I use the 9th (MSB) bit to identify the message address which is then used in the rest of the system.



The UART TX code looks like this, I am using the highlighted line to set the address bit. 


#pragma interrupt_level 0
void uartTxPacket( pkt_t* pPkt )
    struct io_descriptor *io;
    uint8_t n;

    uart_pTxBegin = (uint8_t*)(pPkt);
    uart_pTxGet   = (uint8_t*)(pPkt);
    uart_pTxEnd   = (uint8_t*)(pPkt) + pPkt->pktSize;
    TX_message_length = pPkt->pktSize;

    while (!USART2_Transfer_completed) // wait until previous packet has been fully transferred
    USART2_Transfer_completed = 0;

    // Reset TX buffer
    for (n=0; n<50; n++){USART_2_TXdata[n] = 0x00;}
    // Copy the message in TX buffer
    for (n = 0; n < TX_message_length ; n++){USART_2_TXdata[n] = *uart_pTxGet++;}

    usart_async_get_io_descriptor(&USART_2, &io);
    // Drive the TXE pin high
    gpio_set_pin_level(RS485TXE, 1); // transmit enable
    gpio_set_pin_level(RS485RXE, 1); // receive disable
    // SENDA bit selects address byte
    hri_usart_write_US_CR_reg(USART2, US_CR_SENDA_Msk); // set the address bit
    // Upload the TX buffer and send the data to RS485
    io_write(io, USART_2_TXdata, TX_message_lenght);



However when I read the data the 9th MSB is never set (as shown in the scope data).

The confusing part is that the same code works on a SAME70Q19 board, any help would be much appreciated.


Scope data


Thanks for reading.


This topic has a solution.
Last Edited: Thu. Oct 11, 2018 - 03:57 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For reference 9 bit mode can be enabled on the SAME70 by changing the following:


hpl_usart_config.h (


#define CONF_USART_2_MODE9 0


Then before the bytes are written, update the US CR register:

hri_usart_write_US_CR_reg(USART2, US_CR_SENDA); // set the address bit


Last Edited: Thu. Oct 11, 2018 - 03:57 PM