7 years, 9 months ago.  This question has been closed. Reason: Unclear question

Help with High Speed Serial Port and MODSERIAL

Hello all,

I am having trouble getting 40k of serial data read from a serial camera module (like this one: https://www.adafruit.com/products/397) and sent out to the PC over serial. The camera is setup at 115200 baud, 8n1. The other serial link is with a bluetooth module configured at 57600 8e1. I am using an STM32F411 clocked externally with an 8MHz crystal. printf("SystemCoreClock = %d Hz\n", SystemCoreClock); says that I'm running at 96MHz. I am able to send commands to the camera fine, and it spits back the 40k of image data at 115200 baud just fine. But receiving the data on the stm32, bytes are being skipped.

For example, I tried

MODSERIAL ser2(S2TX, S2RX, 256, 60000);
ser2.baud(115200);
ser2.format(8, SerialBase::None, 1);

... send data to start camera sending serial data ...

while(ser2.rxBufferGetCount() < filesize)
  ;

But ser2.rxBufferGetCount() never gets all the bytes. I verified on the Logic Analyzer that the camera sent all the data. When I send less data back and forth from the camera, all is fine. It's only when I send the large block that bytes are skipped. I've also tried a bunch of other ways of reading the Serial data back, and bytes are skipped in each case. I would have thought that maybe it was a hardware issue, but none of the bytes are corrupted. All the correct values are read. It's just that bytes are being lost from the stream. So I'm pretty sure it's a software issue.

I'm wondering if the mbed system performs tasks that doesn't leave enough time for MODSERIAL to receive the bytes? Can someone tell me what all the mbed system does? I'm using mbed 2.0. So no mbed OS, just the basic mbed functions. I've noticed before that even a simple printf of a string will print part of the string and then there will be a few ms pause before the end of the string is finished (I've seen on the Logic Analyzer). I thought all mbed did was to get an interrupt to update the system timer for wait and time functions. Does it do a lot else? Can certain functions be enabled/disabled? Does anyone else have any ideas? Thanks!

Josh

Maybe this is related. When I do a simple while(1) putc('A'); Every roughly 20ms there is a pause in the byte stream for roughly 2-3 ms. What causes that?

posted by Josh Grauman 28 Jul 2016

Even more baffling to me is it does this even when I disable interrupts with <<code>> __disable_irq(); <</code>> So there is definitely something that the system is doing that is messing me up! Can someone please enlighten me!

posted by Josh Grauman 28 Jul 2016

Sorry for all the posts! But I think I found the culprit. Earlier in my code I had:

t.attach_us(&ticked, 100000);
t.detach(); 

I thought detaching it would make sure the isr wasn't called. I also thought calling <<code>>__disable_irq() <</code>> would stop any isr's from being called. How did the Ticker interrupt make it through both being disabled and having irq's disabled? Note that the function wasn't called, but some sort of isr is still taking up execution time.

posted by Josh Grauman 28 Jul 2016