I have a device (Xmega) sending to the STM32F4 at 9600 8N1 verified (with scope).
Right now I just have a chSequentialStreamRead then calling chprintf and sending the individual bytes out.
Code: Select all
static THD_WORKING_AREA(waCheckSerialThread,256);
static THD_FUNCTION(CheckSerial,arg) {
(void)arg;
uint8_t serial_val;
chRegSetThreadName("CheckSerialThread");
ser = (BaseSequentialStream *)&SD1;
while (1)
{ chSequentialStreamRead(ser,(char *)&serial_val,1);
chprintf(ser,"%c",serial_val);
}
}
If I send 1 single byte from my other processor, it gets it every time. If I send a string of them, I notice that most of the time it gets them, but then just stops at some point and never starts again in that transmission group (meaning sending them out as fast as possible on the other processor).
When it echoes them out, they are always correct. Just don't understand what could happen to prevent it from continuing to get them and not stopping.
Could this be a buffering problem?
Am I using this code incorrectly?
This is how I am setting up the serial pins (and driver):
Code: Select all
const SerialConfig serial_cfg = {
9600, //bitrate
0, //CR1
0, //CR2
0, //CR3
};
palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));
sdStart(&SD1, &serial_cfg);
chThdCreateStatic(waCheckSerialThread, sizeof(waCheckSerialThread), NORMALPRIO,CheckSerial,NULL);
Just not sure what to check next. I have basically a 2k resistor (2 1k in series) between both chips as I wanted to have over-current protection. For 9600 that should be absolutely fine (and the waveforms are fine on the scope).
Thoughts?