-
GD32h759demo错误 sos
[i=s] 本帖最后由 NKML 于 2024-12-2 14:16 编辑 [/i] 大佬们,请教个问题。为啥下载了 GD32H759官方的demo: “06_USART_DMA”, ,用keil编译会失败呢?错误部分的代码是这样的。 void mpu_region_struct_para_init(mpu_region_init_struct *mpu_init_struct) { mpu_init_struct->region_number = MPU_REGION_NUMBER0; mpu_init_struct->region_base_address = 0x00000000U; mpu_init_struct->instruction_exec = MPU_INSTRUCTION_EXEC_PERMIT; mpu_init_struct->access_permission = MPU_AP_NO_ACCESS; //这个提示错误 mpu_init_struct->tex_type = MPU_TEX_TYPE0; mpu_init_struct->access_shareable = MPU_ACCESS_SHAREABLE; mpu_init_struct->access_cacheable = MPU_ACCESS_CACHEABLE; mpu_init_struct->access_bufferable = MPU_ACCESS_BUFFERABLE; mpu_init_struct->subregion_disable = MPU_SUBREGION_ENABLE; mpu_init_struct->region_size = MPU_REGION_SIZE_32B; //这个也提示错误 } 找了半天好像是没有定义这个数值对么,如果要定义的话,数值应该去定义多少呢?
1389浏览量 0回复量 关注量 -
DSP28335中,math.h调用取整函数trunc编译报错, sos
[align=left][font=Arial, Helvetica, sans-serif][size=12px]在DSP28335中,用的是CCS6.2,在main.c中首先包含了math.h,如下:[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px][img=0,240]https://e2echina.ti.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/ce4c46aa_2D00_a133_2D00_464f_2D00_9d6b_2D00_3630b2ccaa04-154057-complete/pastedimage1726107940466v1.png[/img],[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px]然后在main.c中,调用sin,cos,atan,mod等函数都可以正常编译并使用,但是当调用trunc取整函数的时候编译报错,取整类函数ceil也不能使用,报错,如下:[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px][img=0,240]https://e2echina.ti.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/ce4c46aa_2D00_a133_2D00_464f_2D00_9d6b_2D00_3630b2ccaa04-154057-complete/pastedimage1726108090161v2.png[/img],[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px][img=0,240]https://e2echina.ti.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/ce4c46aa_2D00_a133_2D00_464f_2D00_9d6b_2D00_3630b2ccaa04-154057-complete/pastedimage1726108126944v3.png[/img],[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px]然后我的具体调用如下,并更换了多种形式,仍然报错,只要把trunc函数换了就不报错了,[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px][img=0,240]https://e2echina.ti.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/ce4c46aa_2D00_a133_2D00_464f_2D00_9d6b_2D00_3630b2ccaa04-154057-complete/pastedimage1726108235827v4.png[/img][/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px]我检查了math.h中是否包含了trunc,确认包含了,[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px][img=0,240]https://e2echina.ti.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/ce4c46aa_2D00_a133_2D00_464f_2D00_9d6b_2D00_3630b2ccaa04-154057-complete/pastedimage1726108337401v5.png[/img],[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px]然后math.h调用以及文件所在是安装ccs时候默认的,如下:[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px][img=0,240]https://e2echina.ti.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/ce4c46aa_2D00_a133_2D00_464f_2D00_9d6b_2D00_3630b2ccaa04-154057-complete/pastedimage1726108452046v8.png[/img],[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px]里面包含了math.h,然后我在lib中配置如下:[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px][img=0,240]https://e2echina.ti.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/ce4c46aa_2D00_a133_2D00_464f_2D00_9d6b_2D00_3630b2ccaa04-154057-complete/pastedimage1726108520352v9.png[/img]。[/size][/font][/align][align=left][font=Arial, Helvetica, sans-serif][size=12px]请教大佬和专业工程师,我这报错,不能编译是什么原因?[/size][/font][/align]
1912浏览量 0回复量 关注量 -
CW32l083 RTC 偏差值 sos
rtc运行一晚上时间比实际实际快了十多分钟 ,程序运行逻辑,程序运行后5分钟进入休眠模式,10分钟后rtc唤醒并打印当前时间 请教出现这种情况的原因是什么 rtc 配置 void my_rtc_Init(void) { RTC_InitTypeDef RTC_InitStruct = {0}; RTC_InitStruct.DateStruct.Day = 0x20; //设置日期,DAY、MONTH、YEAR必须为BCD方式,星期为0~6,代表星期日,星期一至星期六 RTC_InitStruct.DateStruct.Month = RTC_Month_March; RTC_InitStruct.DateStruct.Week = RTC_Weekday_Wednesday; RTC_InitStruct.DateStruct.Year = 0x24; RTC_InitStruct.TimeStruct.Hour = 0x09; //设置时间,HOUR、MINIUTE、SECOND必须为BCD方式,用户须保证HOUR、AMPM、H24之间的关联正确性 RTC_InitStruct.TimeStruct.Minute = 0x09; RTC_InitStruct.TimeStruct.Second = 0x00; RTC_InitStruct.TimeStruct.AMPM = 0; RTC_InitStruct.TimeStruct.H24 = 1; RTC_InitStruct.RTC_ClockSource = RTC_RTCCLK_FROM_LSI; RTC_Init(&RTC_InitStruct); // 用户需选定需要使用的时钟源 } /* 设置时钟 */ unsigned char at_cmd_setrtc(Timestamp tm){ RTC_DateTypeDef RTC_DateStruct = {0}; RTC_TimeTypeDef RTC_TimeStruct = {0}; RTC_DateStruct.Year = HexToBcd((unsigned char) tm.year); RTC_DateStruct.Month = HexToBcd((unsigned char) tm.month); RTC_DateStruct.Day = HexToBcd((unsigned char) tm.day); RTC_DateStruct.Week = HexToBcd((unsigned char) tm.week); RTC_TimeStruct.Hour = HexToBcd((unsigned char) tm.hour); RTC_TimeStruct.Minute = HexToBcd((unsigned char) tm.minute); RTC_TimeStruct.Second = HexToBcd((unsigned char) tm.second); RTC_TimeStruct.AMPM = 0; RTC_TimeStruct.H24 = 1; RTC_SetTime(&RTC_TimeStruct); RTC_SetDate(&RTC_DateStruct); return 0; } uint8_t *WeekdayStr[7]= {"SUN","MON","TUE","WED","THU","FRI","SAT"}; void showrtctime(void) { char out[20]; RTC_TimeTypeDef RTC_TimeStruct = {0}; RTC_DateTypeDef RTC_DateStruct = {0}; RTC_GetDate(&RTC_DateStruct); RTC_GetTime(&RTC_TimeStruct); sprintf(out,"20%02d-%02d-%02d %s",BcdToHex(RTC_DateStruct.Year),BcdToHex(RTC_DateStruct.Month),BcdToHex(RTC_DateStruct.Day),WeekdayStr[RTC_DateStruct.Week]); printf("current time: %s ",out); sprintf(out,"%02d:%02d:%02d",BcdToHex(RTC_TimeStruct.Hour),BcdToHex(RTC_TimeStruct.Minute),BcdToHex(RTC_TimeStruct.Second)); printf(" %s \r\n",out); } void set_rtcAwk(uint16_t interval) { RTC_AWTTypeDef RTC_AWTStruct = {0}; RTC_AWTCmd(DISABLE); NVIC_DisableIRQ(RTC_IRQn); interval = (uint16_t)(interval*0.125) - 1; printf("set_rtcAwk %d \r\n", interval); showrtctime(); RTC_AWTStruct.AWT_ARRValue = interval; //(interval+1)/0.125 RTC_AWTStruct.AWT_ClockSource = RTC_AWTSOURCE_FROM_RTC1HZ_8; //0.125hz RTC_AWTConfig(&RTC_AWTStruct); RTC_ClearITPendingBit(RTC_IT_AWTIMER); RTC_AWTCmd(ENABLE); RTC_ITConfig(RTC_IT_AWTIMER, ENABLE); NVIC_EnableIRQ(RTC_IRQn); } void RTC_IRQHandlerCallBack(void) { if (RTC_GetITState(RTC_IT_AWTIMER )) { showrtctime(); RTC_ClearITPendingBit(RTC_IT_AWTIMER); } } /****************************************************************************** * Local function prototypes ('static') ******************************************************************************/ void System_Clk_Config(void) { uint8_t res; RCC_HSI_Enable( RCC_HSIOSC_DIV2 ); //配置系统时钟为HSI 24M RCC_LSI_Enable(); RCC_AHBPeriphClk_Enable(RCC_AHB_PERIPH_FLASH, ENABLE); //打开FLASH时钟 FLASH_SetLatency(FLASH_Latency_1); //频率小等于24M需要配置FlashWait=1 REGBITS_SET(CW_FLASH->CR1, FLASH_CR1_STANDBY_Msk); //打开FLASH低功耗使能控制 res = RCC_SysClk_Switch( RCC_SYSCLKSRC_HSI ); //切换系统时钟到HSI if( res == 0x0U ) //切换系统时钟成功 { RCC_SystemCoreClockUpdate(24000000); RCC_HCLKPRS_Config(RCC_HCLK_DIV1); //HCLK(不分频)=PCLK RCC_PCLKPRS_Config(RCC_PCLK_DIV1); } else { while(1) { } } } void RCC_CLK_Config(void) { //外设时钟使能 __RCC_GPIOA_CLK_ENABLE(); __RCC_GPIOB_CLK_ENABLE(); __RCC_GPIOC_CLK_ENABLE(); __RCC_GPIOF_CLK_ENABLE(); __RCC_UART1_CLK_ENABLE(); __RCC_UART2_CLK_ENABLE(); __RCC_UART3_CLK_ENABLE(); __RCC_UART4_CLK_ENABLE(); __RCC_UART5_CLK_ENABLE(); __RCC_UART6_CLK_ENABLE(); //__RCC_SPI1_CLK_ENABLE(); __RCC_RTC_CLK_ENABLE(); __RCC_BTIM_CLK_ENABLE(); __RCC_DMA_CLK_ENABLE(); } /****************************************************************************** * Local variable definitions ('static') * ******************************************************************************/ /****************************************************************************** * Local pre-processor symbols/macros ('#define') ******************************************************************************/ /***************************************************************************** * Function implementation - global ('extern') and local ('static') ******************************************************************************/ /** ****************************************************************************** ** \brief Main function of project ** ** \return uint32_t return value, if needed ** ** This sample HSI switch to PLL, PLL switch to HSI. ** ******************************************************************************/ int32_t main(void) { System_Clk_Config(); RCC_CLK_Config(); //InitTick(24000000); my_rtc_Init(); set_rtcAwk(600); Sleep_Mode_Config(DEEP_SLEEP_MODE); //DEEP_SLEEP_MODE printf("test...\r\n"); while (1) { /* code */ if(1==devParam_t.enter_sleep) { showrtctime(); printf("enter_low_power_consumption_mode...\r\n"); Enter_Deep_Sleep_Mode(); devParam_t.enter_sleep=0; printf("exit_low_power_consumption_mode...\r\n"); showrtctime(); } } }
1636浏览量 0回复量 关注量 -
TIM3捕获配置时,只要一NVIC_Init使能中断就卡死,咨询下大家
STM32F103ZET6板子,想用TIM3_CH2来捕获TIM8 CH3输出的pwm,为此将pwm TIM8_CH3输出的管脚PC8 和 TIM3_CH2管脚PA7 连起来后,发现程序执行不下去了(不连起来就能执行)。卡死了好像。请帮看下可能原因。 做过的尝试: 1、自己把TIM3 CH2的优先级改成最高(抢占优先级为0,响应优先级也为0),也不行。 2、PC8 和 TIM3_CH2管脚PA7 连线去除,发现程序能执行下去 3、中断不使能,就是不执行Nvic_init也可以执行下去,说明肯定是和中断相关。 TIM3_CH2初始化的代码: void InitFan3InletFG(void) { GPIO_InitTypeDef GPIO_InitStructure; TIM_ICInitTypeDef TIM_ICInitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; NVIC_InitTypeDef NVIC_InitStructure; //初始化GPIO复用 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化定时器 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); TIM_TimeBaseStructure.TIM_Period = 0xFFFF-1; TIM_TimeBaseStructure.TIM_Prescaler = 72-1; //1us,总时间65ms TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); /* IC2,上升沿触发 TI2FP2 */ TIM_ICInitStructure.TIM_Channel = TIM_Channel_2; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x0; TIM_PWMIConfig(TIM3, &TIM_ICInitStructure); #if 0 /* IC2, 下降沿触发,TI2FP1*/ TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling; TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_IndirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x0; TIM_PWMIConfig(TIM5, &TIM_ICInitStructure); #endif TIM_SelectInputTrigger(TIM3, TIM_TS_TI2FP2); TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_Reset); TIM_SelectMasterSlaveMode(TIM3,TIM_MasterSlaveMode_Enable); TIM_Cmd(TIM3, ENABLE); //使能CC2捕获中断,主 //// TIM_ClearITPendingBit(TIM3, TIM_IT_CC2); //20231130 1101: try add this TIM_ITConfig(TIM3, TIM_IT_CC2, ENABLE); //使能中断 NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //3; //0; //1; // 3; //20231130pm5 try modified to 1 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; /////// NVIC_Init(&NVIC_InitStructure); ///////1130pm15: disable try NVIC_Init(&NVIC_InitStructure); } 中断处理代码: void TIM3_IRQHandler(void) { Timer3ISR(); } void Timer3ISR(void) { int ret; g_tim3Count++; if (g_tim3Count % 100 == 0) { //printf("timer3 got\r\n"); } TIM_ClearITPendingBit(TIM3, TIM_IT_CC2); TIM_ClearITPendingBit(TIM3, TIM_IT_CC1); TIM_ClearITPendingBit(TIM3, TIM_IT_CC3); TIM_ClearITPendingBit(TIM3, TIM_IT_CC4); //TIM3, CH2通道 ret = TIM_GetFlagStatus(TIM3, TIM_FLAG_CC2); if (ret) { TIM_ClearITPendingBit(TIM3, TIM_IT_CC2); Tim3Ch2Isr(); } //TIM3, CH1通道 ret = TIM_GetFlagStatus(TIM3, TIM_FLAG_CC1); if (ret) { TIM_ClearITPendingBit(TIM3, TIM_IT_CC1); Tim3Ch1Isr(); } //TIM3, CH3通道 ret = TIM_GetFlagStatus(TIM3, TIM_FLAG_CC3); if (ret) { TIM_ClearITPendingBit(TIM3, TIM_IT_CC3); Tim3Ch3Isr(); } //TIM3, CH4通道 ret = TIM_GetFlagStatus(TIM3, TIM_FLAG_CC4); if (ret) { TIM_ClearITPendingBit(TIM3, TIM_IT_CC4); Tim3Ch4Isr(); } }
1513浏览量 1回复量 关注量