2015-08-06 07:41 AM
Hello
I am using NUCLEO L053R8 (STM32L0) , Keil uVision 5.15 and ST-Link (embedded in the nucleus board). I let CubeFx a FW program using CubeFx with HAL enabled.All compiles wellI can use the the blocking transmit functionHAL_UART_Transmit(&huart2, (uint8_t*)txx,sizeof(txx),1000);but the non-blocking, interrupt baseHAL_UART_Transmit_IT(&huart2, (uint8_t*)txx,sizeof(txx));does not work. How do I setup the NVIC as required at the beginning of *_hal_uart.c?(#) Initialize the UART low level resources by implementing the HAL_UART_MspInit() API:
(##) Enable the USARTx interface clock.
(##) UART pins configuration:
(+++) Enable the clock for the UART GPIOs.
(+++) Configure these UART pins as alternate function pull-up.
(##) N
VIC configuration
if you need to use interrupt process (HAL_UART_Transmit_IT()and HAL_UART_Receive_IT() APIs):
(+++) Configure the USARTx interrupt priority.
(+++) Enable the NVIC USART IRQ handle.
It looks like that CubeFX generated a project with no interrupt handling support ... so I have added in the main program the following codevoid USART2_IRQHandler(void){ HAL_UART_IRQHandler(&huart2);}Since I want to write an fputc based on sending a single character, is it available a dedicated API or should I use the same API above with size=1? I tried some piece of code based on accessing the UART registers but I failed ...The issue I have when using the vlocking transmit function is that the baud rate is unaccurate so I am thinking about the clock selection may be wrong ...Is there any example abot using the UART with HAL drivers (the code snippets I find in the STM web site use only MSIS so I am wondering if it is recommended using HAL drivers for simple applications)sorry fo the basic questions (I am a primer here)thanksBelow the CubeFx configuration file#MicroXplorer Configuration settings - do not modifyFile.Version=5KeepUserPlacement=trueMcu.Family=STM32L0Mcu.IP0=ADCMcu.IP1=CRCMcu.IP2=IWDGMcu.IP3=NVICMcu.IP4=RCCMcu.IP5=SYSMcu.IP6=TIM6Mcu.IP7=USART1Mcu.IP8=USART2Mcu.IPNb=9Mcu.Name=STM32L051K(6-8)TxMcu.Package=LQFP32Mcu.Pin0=PA0Mcu.Pin1=PA2Mcu.Pin2=PA3Mcu.Pin3=PA9Mcu.Pin4=PA10Mcu.Pin5=PA13Mcu.Pin6=PA14Mcu.Pin7=VP_CRC_VS_CRCMcu.Pin8=VP_IWDG_VS_IWDGMcu.Pin9=VP_TIM6_VS_ClockSourceINTMcu.PinsNb=10Mcu.UserConstants=Mcu.UserName=STM32L051K6TxMxCube.Version=4.9.0MxDb.Version=DB.4.0.90NVIC.SysTick_IRQn=true\:0\:0\:falsePA0.Mode=IN0PA0.Signal=ADC_IN0PA10.Mode=AsynchronousPA10.Signal=USART1_RXPA13.Mode=Serial_WirePA13.Signal=SYS_SWDIOPA14.Mode=Serial_WirePA14.Signal=SYS_SWCLKPA2.Mode=AsynchronousPA2.Signal=USART2_TXPA3.Mode=AsynchronousPA3.Signal=USART2_RXPA9.Mode=AsynchronousPA9.Signal=USART1_TXPCC.Checker=falsePCC.Line=STM32L0x1PCC.MCU=STM32L051K(6-8)TxPCC.MXVersion=4.9.0PCC.PartNumber=STM32L051K6TxPCC.Seq0=0PCC.Series=STM32L0PCC.Temperature=25PCC.Vdd=nullProjectManager.AskForMigrate=trueProjectManager.BackupPrevious=falseProjectManager.CompilerOptimize=2ProjectManager.ComputerToolchain=falseProjectManager.CoupleFile=falseProjectManager.DeletePrevious=trueProjectManager.DeviceId=STM32L051K6TxProjectManager.FirmwarePackage=STM32Cube FW_L0 V1.1.2ProjectManager.FreePins=falseProjectManager.HalAssertFull=falseProjectManager.KeepUserCode=trueProjectManager.LastFirmware=trueProjectManager.LibraryCopy=1ProjectManager.ProjectBuild=falseProjectManager.ProjectFileName=ECM_BLDC.CTRL.iocProjectManager.ProjectName=ECM_BLDC.CTRLProjectManager.TargetToolchain=MDK-ARM V5ProjectManager.ToolChainLocation=RCC.AHBFreq_Value=2097000RCC.APB1Freq_Value=2097000RCC.APB1TimFreq_Value=2097000RCC.APB2Freq_Value=2097000RCC.APB2TimFreq_Value=2097000RCC.ClockTypeSysClk=RCC_CLOCKTYPE_SYSCLKRCC.FamilyName=MRCC.HSI16_VALUE=16000000RCC.HSI_VALUE=16000000RCC.I2C1Freq_Value=2097000RCC.IPParameters=FamilyName,LSE_VALUE,MSI_VALUE,HSI16_VALUE,HSI_VALUE,LSI_VALUE,WatchDogFreq_Value,VCOOutputFreq_Value,PLLCLKFreq_Value,RTCFreq_Value,SYSCLKFreq_VALUE,AHBFreq_Value,TIMFreq_Value,APB1Freq_Value,APB1TimFreq_Value,LPTIMFreq_Value,I2C1Freq_Value,APB2Freq_Value,APB2TimFreq_Value,USART1Freq_Value,PWRFreq_Value,USART2Freq_Value,ClockTypeSysClkRCC.LPTIMFreq_Value=2097000RCC.LSE_VALUE=32768RCC.LSI_VALUE=37000RCC.MSI_VALUE=2097000RCC.PLLCLKFreq_Value=24000000RCC.PWRFreq_Value=2097000RCC.RTCFreq_Value=37000RCC.SYSCLKFreq_VALUE=2097000RCC.TIMFreq_Value=2097000RCC.USART1Freq_Value=2097000RCC.USART2Freq_Value=2097000RCC.VCOOutputFreq_Value=48000000RCC.WatchDogFreq_Value=37000VP_CRC_VS_CRC.Mode=CRC_ActivateVP_CRC_VS_CRC.Signal=CRC_VS_CRCVP_IWDG_VS_IWDG.Mode=IWDG_ActivateVP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDGVP_TIM6_VS_ClockSourceINT.Mode=Enable_TimerVP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINTboard=ECM_BLDC.CTRL
2015-08-31 06:53 AM
Hi stanzani.marco,
You can find the example you are looking for under STM32Cube_FW_L0\Projects\STM32L053R8-Nucleo\Examples\UART\UART_TwoBoards_ComIT.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.