osDelay(x) behaviour

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
plamen
Posts: 11
Joined: Thu Feb 02, 2017 9:47 am
Has thanked: 1 time
Been thanked: 2 times

osDelay(x) behaviour

Post by plamen »

Hello,
I can't explain the behavior of the following code, compiled on STM32F105 with Chibios 16.1.8:
for (uint32_t i = 0; i < size; ++i) {
sdWrite(DRV, &data[i], 1);
osDelay(time);
}
Send data on the serial line, there should be a pause between each byte - time in ms
When I observe the transmission with oscilloscope, I see that the pause is exactly (time - 1) ms. If time == 1 -> no delay between the bytes, if time == 2, then there is exactly 1 ms between the end of the stop bit and the start bit of the next byte.

I tried to play with osDelay(..) and simple GPIO change - everything on the line as expected - no -1 shift
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: osDelay(x) behaviour

Post by Giovanni »

Hi,

Probably this is because sdWrite() takes more than 1mS when the queue is full, consider the transmission time.

Giovanni
plamen
Posts: 11
Joined: Thu Feb 02, 2017 9:47 am
Has thanked: 1 time
Been thanked: 2 times

Re: osDelay(x) behaviour

Post by plamen »

Thanks!
At my baud rate the transmission time is almost exactly 1ms per byte. I incorrectly assumed that sdWrite blocks until all has completed. But it blocks until the data byte goes in the transmission register TDR.
Post Reply