AnsweredAssumed Answered

Problem using UART

Question asked by soumaya BEN MANSOUR on May 5, 2017
Latest reply on May 23, 2017 by soumaya BEN MANSOUR

Hi community,

 

I'm using stm32f769i-disco to make a serial communication with a Vacuum Transducer (925 MicroPirani).The 925 transducer can provide pressure mesurement output as RS232 digital value.

 

Pressure request :

Query: @253PR1?;FF

Query reply: @253ACK9.00E+2;FF

 

The discovery card transmit the request bufftr[30] = @253PR1?;FF via the HAL_UART_Transmit(&UartHandle, bufftr, 30, 100)

and the 925 transducer send the pressure value that is to say that the discovery card receive the reply for her request via HAL_UART_Receive(&UartHandle, buffrec, 30, 100); buffrec[30]=@253ACK9.00E+2;FF 

 

Then I use double pression to get just the bit 7,12,13 of the buffrec and finally I display this value in the LCD.

 

Here is my code:

int main(void)
{

  MPU_Config();

CPU_CACHE_Enable();

 HAL_Init();

SystemClock_Config();

/* Enalbe clock for USART6 and GPIOC */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_USART6_CLK_ENABLE();
__HAL_UART_ENABLE(&UartHandle);

/* Initialize GPIOC */
MX_GPIOC_Init();
/* Initialize USART6 */
MX_USART6_UART_Init();

/*##-2- Configure the LCD peripheral #########################################*/
LCD_Config();

uint8_t bufftr[30] = "@253PR1?;FF";
uint8_t buffrec[30];

double pression;
char pressbuf [20];

/* Infinite loop */
while (1)
{
/*Transmitting and receiving data */

HAL_UART_Transmit(&UartHandle, bufftr, 30, 100);
HAL_UART_Receive(&UartHandle, buffrec, 30, 100);
HAL_Delay(1000);
if (buffrec[12]==43)
{
pression = (buffrec[7]-48)*pow(10,(buffrec[13]-48));// buffrec7 en ascii c'est 57 - 48 = 9
}
if (buffrec[12]==45)
{
pression = (buffrec[7]-48)*pow(10,-(buffrec[13]-48));
}

/* Display the Pression Value on the LCD */

snprintf(pressbuf, 17, "Vacuum : %fmBar",pression);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 + 45, (uint8_t *)pressbuf, CENTER_MODE);
BSP_LCD_ClearStringLine(30);
}
}

 

Finally I don't get my presion value, I only get Vacuum : 0.00000 mBar.

I tried to understand what is wrong with my code I use breakpoint but when I click in step over my code doesn't respect the steps , it is supposed to transmit the request then receive the reply then get the pression then display it on the lcd. 

 

Can anyone help me to know what I'm missing?

 

thanks in advance

Outcomes