Using the Serial Driver to exchange data over UART but it stops the USB function
Posted: Tue Feb 11, 2020 4:20 pm
Good Day,
I work with a custom developed board. The board uses a STMF405 package and we use ChibiOS also. Now the problem I am facing is that I have setup the serial driver to use USART1. and the USB is using USART2. what happens is with the USART1 implementation the usb functionality stops and as soon as i remove the USART1 stuff the usb starts working again. Below are some areas where I use the UART!(Serial Driver) implementation. I tried to debug alot but didn't reach to a conclusion. Any help will be appreciated. Thank You.
********************************************************************************************************************************
(CONFIGURATION)
static const SerialConfig mySerialConfig =
{
9600,
0,
USART_CR2_STOP_1,
0
};
myFunction(){
.....
sdStart(&SD1, &mySerialConfig);
.....
}
(USE )
unsigned char received[10] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff, 0xff ,0xff};
void requestData(int8_t startFlag, int8_t slaveAdd, int8_t rw, int8_t dataADD,
int8_t dataLength, int8_t checkSum) {
sdWriteTimeout(&SD1, (int8_t*) startFlag, 8,10);
sdWriteTimeout(&SD1, (int8_t*) slaveAdd, 8,10);
sdWriteTimeout(&SD1, (int8_t*) rw, 8,10);
sdWriteTimeout(&SD1, (int8_t*) dataADD, 8,10);
sdWriteTimeout(&SD1, (int8_t*) dataLength, 8,10);
sdWriteTimeout(&SD1, (int8_t*) checkSum, 8,10);
// one of the formats should work
// sdWrite(&SD1 , startFlag , 8 );
// sdWrite(&SD1 , slaveAdd , 8 );
// sdWrite(&SD1 , rw , 8 );
// sdWrite(&SD1 , dataADD , 8);
}
void readData(void) {
sdReadTimeout(&SD1, received, 10, 10);
}
void something() {
static uint32_t stored_AT_values;
unsigned char dummyBuffer[4];
static const unsigned long reading_prescalar = 500; // every 5 milliseconds
static unsigned int reading_prescalar_index = 1;
if (reading_prescalar_index >= reading_prescalar) {
if (process_finished == 0) {
if (chnReadTimeout(&PORTAB_SDU1, dummyBuffer, 4, TIME_IMMEDIATE)
== 4) //somehow not working without this
{
stored_AT_values = ReadATValues();
process_finished = 1;
}
}
else if (process_finished == 1) {
send_buffer_to_usb((unsigned char*) received, 10);
chnGetTimeout(&PORTAB_SDU1, TIME_INFINITE);
in_calibration_process = false;
}
reading_prescalar_index = 0;
}
reading_prescalar_index++;
}
*****************************************************************************************************************************
I work with a custom developed board. The board uses a STMF405 package and we use ChibiOS also. Now the problem I am facing is that I have setup the serial driver to use USART1. and the USB is using USART2. what happens is with the USART1 implementation the usb functionality stops and as soon as i remove the USART1 stuff the usb starts working again. Below are some areas where I use the UART!(Serial Driver) implementation. I tried to debug alot but didn't reach to a conclusion. Any help will be appreciated. Thank You.
********************************************************************************************************************************
(CONFIGURATION)
static const SerialConfig mySerialConfig =
{
9600,
0,
USART_CR2_STOP_1,
0
};
myFunction(){
.....
sdStart(&SD1, &mySerialConfig);
.....
}
(USE )
unsigned char received[10] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff, 0xff ,0xff};
void requestData(int8_t startFlag, int8_t slaveAdd, int8_t rw, int8_t dataADD,
int8_t dataLength, int8_t checkSum) {
sdWriteTimeout(&SD1, (int8_t*) startFlag, 8,10);
sdWriteTimeout(&SD1, (int8_t*) slaveAdd, 8,10);
sdWriteTimeout(&SD1, (int8_t*) rw, 8,10);
sdWriteTimeout(&SD1, (int8_t*) dataADD, 8,10);
sdWriteTimeout(&SD1, (int8_t*) dataLength, 8,10);
sdWriteTimeout(&SD1, (int8_t*) checkSum, 8,10);
// one of the formats should work
// sdWrite(&SD1 , startFlag , 8 );
// sdWrite(&SD1 , slaveAdd , 8 );
// sdWrite(&SD1 , rw , 8 );
// sdWrite(&SD1 , dataADD , 8);
}
void readData(void) {
sdReadTimeout(&SD1, received, 10, 10);
}
void something() {
static uint32_t stored_AT_values;
unsigned char dummyBuffer[4];
static const unsigned long reading_prescalar = 500; // every 5 milliseconds
static unsigned int reading_prescalar_index = 1;
if (reading_prescalar_index >= reading_prescalar) {
if (process_finished == 0) {
if (chnReadTimeout(&PORTAB_SDU1, dummyBuffer, 4, TIME_IMMEDIATE)
== 4) //somehow not working without this
{
stored_AT_values = ReadATValues();
process_finished = 1;
}
}
else if (process_finished == 1) {
send_buffer_to_usb((unsigned char*) received, 10);
chnGetTimeout(&PORTAB_SDU1, TIME_INFINITE);
in_calibration_process = false;
}
reading_prescalar_index = 0;
}
reading_prescalar_index++;
}
*****************************************************************************************************************************