2015-01-31 07:03 AM
I create a program for uart interrupt receiving by cubeMX in ARM-MDK.
I want interrupt receivng from PC(when for example 0xFF received from pc by hyperterminal or docklight). I write bellow program. main() { while (1) { if(HAL_UART_Receive_IT(&huart6, (uint8_t *)aRxBuffer, 8) != HAL_OK) { HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_13); HAL_Delay(0x000000ff); } HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_12); HAL_Delay(0x000000ff); } } /////////////////////////////////////////////////// void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) { HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_15); } but not work.Please help me.2015-02-02 12:40 AM
You might want to start with reviewing and reproducing the examples contained within the Cube package.
JW2015-02-02 11:29 AM
hi
I read cube example but i don't know. do you have a simple example?2015-02-02 12:28 PM
do you have a simple example?
Not a HAL one.2015-02-03 06:38 AM
2015-02-06 03:04 AM
Hi ramin!
while (1) and IRQ metod - not very compatible ;) If you want to call the reception of the cycle, - you ned HAL function HAL_UART_Receive (NOT HAL_UART_Receive_IT ! ) as example : while (1) { if (HAL_UART_Receive ( &huart2, aTxBuffer, 8, 5000 ) == HAL_OK) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); HAL_Delay(100); HAL_UART_Transmit( &huart2, aTxBuffer, 8, 5000 ); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); } ================================================ If you want to call the reception of the interrupt -use HAL_UART_Receive_IT() with void USARTx_IRQHandler(void) { HAL_UART_IRQHandler(& UartHandle); } check whether this function in the file : stm32f4xx_it.c and check - whether this function in the file : stm32f4xx_hal_msp.c HAL_NVIC_EnableIRQ(USART2_IRQn); ====================================================2015-02-06 03:12 AM
waclawek.jan +1
for sure!
lock in d: \ _ ST_ \ STM32Cube \ Projects \ STM32F401-Discovery \ Examples \ UART \UART_TwoBoards_ComPolling - a simple method \UART_TwoBoards_ComIT - based on interrupts \UART_TwoBoards_ComDMA - DMA on IRQ method2015-02-06 11:09 AM
hi nazarov
I edit my code as bellow(I want use of uart interrupt driven receiving)://------------------------------------------------------------------------
UART_HandleTypeDef huart6;int
main(void
) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART6_UART_Init(); HAL_UART_Receive_IT(&huart6, (uint8_t *)aRxBuffer, 8);while
(1) { HAL_GPIO_WritePin(GPIOD,GPIO_PIN_13,GPIO_PIN_SET); HAL_Delay(1000); } }void
HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) { HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_SET); } and I look at stm32f4xx_it.c that contain bellow code:void
USART6_IRQHandler(void
) { HAL_UART_IRQHandler(&huart6); } but myproblem(
not working HAL_UART_RxCpltCallback()
) exist. do you have any idea? thank.2015-02-06 11:28 AM
and in stm32f4xx_hal_msp.c I find this code:
/* System interrupt init*/
HAL_NVIC_SetPriority(USART6_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART6_IRQn); thank