• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

UART on expansion board 1LC

Scheduled Pinned Locked Moved
Firmware developers
2
5
144
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    JoA-RHU
    last edited by JoA-RHU 11 May 2024, 08:58 5 Nov 2024, 08:01

    Hi,

    I'm trying to implement a serial communication on the TOOL1LC firmware (v3.5.3) using pins PA09 and PA12 (io0.in/out). So far, I managed to transmit what I want from the board, but I can't receive proper data and I don't understand why.

    Regarding the ports configuration and serial initialization this is what I've done:

    void SerialPortInit(AsyncSerial*) noexcept
    {
    SetPinFunction(PortAPin(9), GpioPinFunction::D); // Rx on PA09, sercom 2, pad 1
    SetPinFunction(PortAPin(12), GpioPinFunction::C); // Tx on PA12, sercom 2, pad 0
    }
    void SerialPortDeinit(AsyncSerial*) noexcept
    {
    pinMode(PortAPin(9), PinMode::PIN_MODE_NOT_CONFIGURED);
    pinMode(PortAPin(12), PinMode::PIN_MODE_NOT_CONFIGURED);
    }
    AsyncSerial uart0(2, 1, 128, 128, SerialPortInit, SerialPortDeinit);
    extern "C" void SERCOM2_Handler()
    {
    uart0.Interrupt();
    }

    Then, uart0 is used in a handler to send and read data periodically (it is spinning in the heating task, so every 250ms).

    Sending data works perfectly with method uart0.write(..), but when data is uart0.available() I get only 0s (null) when I uart0.read().

    I know uart is officially not supported on expansion boards, but this is the only option I have to communicate with the device I want to use. And I don't have the knowledge to build a completely new expansion board using a SammyC21, in terms of electronics.

    Any help or hint would be greatly appreciated.
    Thanks

    undefined 1 Reply Last reply 5 Nov 2024, 11:34 Reply Quote 0
    • undefined
      dc42 administrators @JoA-RHU
      last edited by 5 Nov 2024, 11:34

      @JoA-RHU I don't know whether this is the cause of your issue, however you also need to set the priority of the UART interrupt to NvicPriorityUart. This is normally done in Platform::InitialiseInterupts.

      Duet WiFi hardware designer and firmware engineer
      Please do not ask me for Duet support via PM or email, use the forum
      http://www.escher3d.com, https://miscsolutions.wordpress.com

      1 Reply Last reply Reply Quote 0
      • undefined
        JoA-RHU
        last edited by 5 Nov 2024, 11:42

        @dc42 Indeed, this is done in Platform::InitialiseInterupts like that:

        ...
        #elif SAMC21
        NVIC_SetPriority(StepTcIRQn, NvicPriorityStep);
        NVIC_SetPriority(CAN0_IRQn, NvicPriorityCan);
        # if NUM_SERIAL_PORTS >= 1
        NVIC_SetPriority(Serial0_IRQn, NvicPriorityUart);
        # endif
        ...

        And I've defined Serial0_IRQn as SERCOM2_IRQn.

        undefined 1 Reply Last reply 5 Nov 2024, 12:03 Reply Quote 0
        • undefined
          dc42 administrators @JoA-RHU
          last edited by 5 Nov 2024, 12:03

          @JoA-RHU What baud rate are you using? There is a 10K/2n2 deglitch filter formed by R4 and C28 on IO0_IN. The time constant is 22us so baud rates above 9600 or perhaps 19200 are unlikely to work.

          Duet WiFi hardware designer and firmware engineer
          Please do not ask me for Duet support via PM or email, use the forum
          http://www.escher3d.com, https://miscsolutions.wordpress.com

          1 Reply Last reply Reply Quote 0
          • undefined
            JoA-RHU
            last edited by 5 Nov 2024, 12:27

            @dc42 I see... I was trying to use the default baud rate of the device I communicate with, which is 57600. I tested with 9600 and it seems much better!
            Thank you very much! I would never have thought of such a thing...

            1 Reply Last reply Reply Quote 0
            4 out of 5
            • First post
              4/5
              Last post
            Unless otherwise noted, all forum content is licensed under CC-BY-SA