0
\$\begingroup\$

I'm making UART support for SAM3x8e based Arduino Due board. I would like to clarify questions I can't resolve by searching the web.

  1. Is it only one IRQ handler per MCU component like USART? This means that I should use status register of component to find out what event exactly occurred?

  2. Is it just enough to define function with predefined name like

void USART0_Handler(void) {}

for USART0 component and USART1_Handler for USART1 and etc.?

  1. The MCU has UART, USART0, USART1, USART2, USART3 devices (components) on board. I looked into arduino source code, exactly
arduino-1.5.7/hardware/arduino/sam/variants/arduino_due_x/variant.cpp

and see that for serial0 UART component is used, for serial1 USART0 is used, for serial2 - USART1 and for serail3 - USART3. The USART2 is not even mentioned. The question why is this done that way? What does the UART, USART0, USART1, USART2, USART3 mean? I would like to know what names should I use to properly communicate through board's pins like TX0/RX0, TX1/RX1 and etc.

Thanx in advance.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

There is generally only one interrupt handler per component, so yes, you will have to check the status register to see what happened. As far as setting up an interrupt handler, the chip has a register that needs to be pointed at the interrupt table somewhere. I'm not sure how that would be set up with your libraries; it could be taken care of in the linker or there could be a library to manage the table.

\$\endgroup\$
3
  • \$\begingroup\$ The names (like USART0) I talk about are defined in sam3xa.h header (from Atmel) via: #define USART0 ((reg_type*)(addr)). I interested in what exactly component corresponds to Arduino Due tx/rx pins? And why they (Arduino authors) use UART as serial0 and not USART0? \$\endgroup\$
    – 4xy
    Commented May 26, 2015 at 19:16
  • \$\begingroup\$ If you are asking about the arduino libraries specifically, you should ask in the arduino stack exchange. I am not an expert on the internals of the arduino libraries. \$\endgroup\$ Commented May 26, 2015 at 19:45
  • \$\begingroup\$ No, I'm not asking about arduino libs. I would like to realize what those comonents (USARTx & UART) are. Is UART is the subset of USART0? What would be the right techinque to handle write port case in the context of IRQ. In SAM3x8e there are TXRDY, ENDTX, TXEMPTY, TXBUFE. If I enable either of them I get handler always called (in idle when no writes to port). Is this mean I should enable TXRDY e.g. only after first byte sent to THR and should it be disabled when the last byte is sent? \$\endgroup\$
    – 4xy
    Commented May 27, 2015 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.