No announcement yet.

Clock/Edge Generator using the second serial port

  • Filter
  • Time
  • Show
Clear All
new posts

  • Clock/Edge Generator using the second serial port

    I am need of a semi accurate Clock/edge generator to pulse a stepper motor driver. I have tried bit banging one of the GPIO pins and while this works, its very disruptive to some of the time critical work that I need to do. I have found that the time to update some of the screen elements can be many milliseconds long and this causes the stepper motor to stutter when I am moving it so I need a back ground HW method to create these pulses

    Since I just need semi-accurate edges, I am planning on just using the second serial port and carefully crafted baud rates and characters to create the desired wave forms. These strings of characters could be 40-100 characters long and I would like the data to be continuous with no pauses between the characters being sent out. .To help me understand if this is even possible could you answer the below question?

    Does com_init create a buffer and use a DMA to transfer the data to the UART from memory?

    or does the UART HW have a mult-entry buffer that is serviced by a background interrupt that we can see and will a massive screen update interrupt servicing this buffer?

    or does the UART just have a single entry buffer the the CPU must constantly poll to know when it has more more space available.

    What would you suggest I use to keep the serial port TX line 100% active during the transmission of these 40-100 characters?


  • #2
    Nothing like that, the TX buffer is managed using interrupts, so not quite as fast as DMA, but it should hopefully work for your purpose.
    You will need to set up a com1_TXbuffer(), use 0 for the turnaround pin.
    Before you start a movement issue com1_TXbufferHold(ON), write everything to the serial port in the 'usual way' and then issue com1_TXbufferHold(OFF), the data should then flow at as close to the maximum speed as possible.


    • #3
      This is up and running and runs great. Nice clean square wave. Baud rate is slow so that helps
      Attached Files