I am having trouble making a very simple transmission between two STM32F3 Discovery boards. Let me explain what I'm doing.
I have Board-A connected via i2c to an LCD 20x4 and Board-B connected via i2c to a Qrobot 3D Gesture Sensor, the goal is to catch the movement from Board-B, blink some leds on the same board and send a number via UART (uart4) to the BoardA.
The problem is that although the debug shows that the transmission takes place, actually the Board-A never enters in the callback of RxCpltCallback. Before dive into the topic with more details, lets me show you the code:
This is the Receive callback of the Board-A. (Also this probram was tested receiving via Uart4 from another F3 (that F3 was sending also via uart4 but in the callback of the BushButton))
void HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart)
{
switch (recvbuff)
{
case 1:
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_9);
lcd_send_string(up);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break; //causa l'uscita immediata dallo switch
case 2:
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_10);
lcd_send_string(down);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
case 3:
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_11);
lcd_send_string(left);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
case 4:
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_12);
lcd_send_string(right);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
case 5:
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_13);
lcd_send_string(forward);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
case 6:HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_14);
lcd_send_string(backward);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
case 7:
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_15);
lcd_send_string(clockwise);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
case 8:
lcd_send_string(anticlockwise);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
case 9:
lcd_send_string(wave);
for(int i=0;i<5000000;i++){
count1=count+1;
}
count1=0;
lcd_send_cmd (0x01);
break;
default:
break;
}
HAL_UART_Receive_IT(&huart4, (uint8_t*)&recvbuff, sizeof(uint32_t));
}
This seems to work properly, I don't think the problem is here.
Let's look the code of Board-B: this program have to check, in a loop, some flags that stands for the gesture, when one occurs blink some leds and send via huart a number, a really simple task!
while (1)
{
/* USER CODE END WHILE */
Gesture_Data = DEV_I2C_ReadWord(PAJ_INT_FLAG1);
if (Gesture_Data)
{
switch (Gesture_Data)
{
case PAJ_UP: { send(1);
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_9);
break;}
case PAJ_DOWN: { send(2);
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_13);
break;}
case PAJ_LEFT: { send(3);
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_15);
break;}
case PAJ_RIGHT: { send(4);
break;}
/* other cases */
default: break;
}
Gesture_Data=0;
DEV_Delay_ms(50);
}
}
In order to test via debugging and brekpoint I have created a separated function only for the trasmit (Also tried the HAL_UART_Transimit(&huart4, (uint8_t *)num, sizeof (uint32_t), HAL_MAX_DELAY)):
void send(uint32_t num)
{
HAL_UART_Transmit_IT(&huart4, (uint8_t *)num, sizeof (uint32_t));
}
When I try this code on the board, the sensore recognize the gesture and blink the correct led, in the debugging I can see crearly that I enter in the function sed() of the trasmit but nothing arrive on the other Board. P.S: every cable connecting the two boards work fine and are on the correct Pins.
What do you think of it? I can't get my mind off this problem!