cancel
Showing results for 
Search instead for 
Did you mean: 

how can we send binary data on two different pins simultaneously on both the rising edge and falling edge of dclk whose speed can be 1MHz on stm32f4?

SAMIN.1
Associate III

PCA is managed by a full-duplex serial interface. A typical data frame is defined by

a burst of 8 DCLK pulses followed by an assertion of a DLOAD pulse (these lines are driven by the host printing system.). During each frame, 32 bits of control or print data (16 bits each, on DIN_1 and DIN_2) are transferred from the host printing system. Input data (to the controller ASIC) is clocked on both the rising and falling edges of DCLK. 

I have also attached a waveform image.

I have also written a code, it works perfectly but the speed is too slow.

code:

HAL_GPIO_WritePin(DLOAD_GPIO_Port, DLOAD_Pin, GPIO_PIN_RESET);

  for (int i = 0; i < 8; i++)

  {

    c = din2 & 1;

    d = din1 & 1;

    uint16_t e = 0x0000;

    e = e | c;

    e = e << 1;

    e = e | d;

    din2 >>= 1;

    din1 >>= 1;

   GPIOB->ODR = e;               //Write to port-b

   HAL_GPIO_WritePin(DCLK_GPIO_Port, DCLK_Pin, GPIO_PIN_SET);

    c = din2 & 1;

    d = din1 & 1;

    e = 0x0000;

    e = e | c;

    e = e << 1;

    e = e | d;

    din2 >>= 1;

    din1 >>= 1;

   GPIOB->ODR = e;               //Write to port-b

   HAL_GPIO_WritePin(DCLK_GPIO_Port, DCLK_Pin, GPIO_PIN_RESET);

  }

therefore anyone can suggest a better method to implement the desired waveform.

Either SPI or I2c can be utilized or not. because both can transfer data on a single gpio pin.

14 REPLIES 14

i am using STM32F407. Microcontroller clock(HCLK) = 150Mhz.

TIM1 is used for microsecond delay.

TIM2 is used for nanosecond delay.

TIM3 is used for PWM.

TIM8 is used for ENCODER.

any other option than using two external SPI modules?

not have*

If the STM32 is generating the clock, just use the TIM trigger directly. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief II

In your subject is 1MHz. For max speed you need prepare packet in memory for example

1000bytes data to send is 8000 bits /2 4000 on dual bit serial.

for DCLK you need shift half clock against data, then in real you need 8000 words for DMA 3 bit GPIO.

When data in memory is prepared you start DMA to GPIO. = max speed.

Simmilar way you can use PWM on one timer and use DMA. This way is simpler maybe.

Paul1
Lead

((Future: Change ASIC to use Standard SPI or QSPI interfaces))

Which side sources clock? (MCU or ASIC)

MCU isn't going to support MBytes of data at full speed, even if only part of data is useful the code couldn't run fast enough to pick out the important pieces on the fly. To store MBytes of data for prep or post processing you might have to implement a fast RAM like used for LCD displays.