Friday, 10 February 2017

microcontroller - STM32F031K6 HAL UART Interrupts problem


enter image description hereI got a new STM32F0 31 K6 nucleo board and I need to make a GSM UART interface on that board. I need to send an AT and receive an OK from the GSM board as a first step.I am able to transmit AT successfully But cannot receive anything. I am using IAR. I am using PA9 - TX and PA10 - RX. How to create a transmit and receive code using interrupts using this HAL library. I wrote code using interrupts and it's not giving a single character. This is my code


     int main(void)
{

HAL_Init();
/* Configure the system clock to 48 MHz */
SystemClock_Config();

/* Configure LED3 */
BSP_LED_Init(LED3);
UART_Init();
BSP_LED_Off(LED3);
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE,100)!= HAL_OK)
{
Error_Handler();
}

if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer,6) != HAL_OK)

{
Error_Handler();
}
/*##-5- Wait for the end of the transfer ###################################*/
while (UartReady != SET)
{
}
/* Reset transmission flag */
UartReady = RESET;
/*if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aRxBuffer, 6,1000)!= HAL_OK)

{
Error_Handler();
}*/
while (1)
{
}
}

IRQ handler


void USARTx_IRQHandler(void)

{
HAL_UART_IRQHandler(&UartHandle);
}

Receive callback function


void  HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{
if(UartHandle->Instance == USARTx)
{
/* Set transmission flag: transfer complete */

UartReady = SET;
BSP_LED_On(LED3);
}
}

And when I am debugging the code stuck at this point .


/*##-5- Wait for the end of the transfer ###################################*/   
while (UartReady != SET)
{
}


My actual application is to send an SMS to the GSM board using UART and collect the reply in a buffer and then parse it.First i need to make this interface And I cannot use DMA as there is no idea on how much data is received on this commuunication.


please help guys..


Regards, olivia




No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...