Skip to main content
John Doe1
Associate III
February 6, 2017
Question

How to send additional bit?

  • February 6, 2017
  • 4 replies
  • 2083 views
Posted on February 06, 2017 at 18:09

Hello,

I'm trying to implement a software that will allow me to send additional one pulse (on the data wire and clock wire). After one pulse I should send data (32 bits) over spi.

Frame should look like:

1 bit + 32 bit

clock pulse every bit

I tried to send 0x80 over SPI and USART but no luck - for 0x80 i have 8 clock pulses. How to implement one clock pulse? PWM? Timers? Dma? 

I would be grateful for every idea !

John

#solution-needed #idea-needed
    This topic has been closed for replies.

    4 replies

    howard n2wx
    Associate III
    February 6, 2017
    Posted on February 06, 2017 at 18:18

    Momentarily flip the data and clock lines into GPIO mode and as outputs, start a timer for one bit time, flip them back when the timer runs? 

    John Doe1
    John Doe1Author
    Associate III
    February 6, 2017
    Posted on February 06, 2017 at 18:28

    Thanks, that's a good idea but using that solution i'll propably lose on performance for a larger sets of data.

    howard n2wx
    Associate III
    February 6, 2017
    Posted on February 06, 2017 at 18:55

    Does your part's USART support 9 bit mode?

    John Doe1
    John Doe1Author
    Associate III
    February 6, 2017
    Posted on February 06, 2017 at 18:33

    I would like to mention that SPI is not required. It's about synchronized data send (one bit per one clock pulse)

    John Doe1
    John Doe1Author
    Associate III
    February 6, 2017
    Posted on February 06, 2017 at 19:41

    Is there no solution to generate synchronized PWM with clock pin?

    Tesla DeLorean
    Guru
    February 6, 2017
    Posted on February 06, 2017 at 22:30

    No, the peripherals are of pretty simple and limited functionality. Want to do odd things, use an FPGA/CPLD

    Want to send 8x 33-bit values, have the SPI DMA 33x 8-bit values where your 32-bit data is slewed across the buffer.

    Use TIM1/8 in One-Pulse, 33x Repetition (or x66 for transitions), and DMA to GPIOx->BSRR, from a pattern buffer.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    John Doe1
    John Doe1Author
    Associate III
    February 8, 2017
    Posted on February 08, 2017 at 20:18

    8x33-bit? You mean 33 bytes?

    Andrew Kitaev
    Associate
    February 9, 2017
    Posted on February 09, 2017 at 13:59

    I had a similar task.

    One solution is to switch to 11-bit mode and send three 'words' of 11 bits. Of course with prior bit shifting and splitting of original 32-bit data.

    waclawek.jan
    Super User
    February 9, 2017
    Posted on February 09, 2017 at 14:41

     ,

     ,

    The 3x11 trick may be nice but possible only on newer STM32s which have more flexible setting than the '

    SPI which allows only 8 or 16 bit frames.

    JW