问答

汇集网友智慧,解决技术难题

Amazingxixixi

TA的家园币:264  

  • GD32F103C8T6,使用ST标准库,CAN初始化失败

    本帖最后由fw19876311于2025-1-1417:01编辑STM32F103C8T6正常运行的代码,直接平替GD32F103C8,CAN部分初始化异常,一直返回失败uint8_tCAN_Init(CAN_TypeDef*CANx,CAN_InitTypeDef*CAN_InitStruct){uint8_tInitStatus=CAN_InitStatus_Failed;uint32_twait_ack=0x00000000;/*Checktheparameters*/assert_param(IS_CAN_ALL_PERIPH(CANx));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TTCM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_ABOM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_AWUM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_NART));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_RFLM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TXFP));assert_param(IS_CAN_MODE(CAN_InitStruct->CAN_Mode));assert_param(IS_CAN_SJW(CAN_InitStruct->CAN_SJW));assert_param(IS_CAN_BS1(CAN_InitStruct->CAN_BS1));assert_param(IS_CAN_BS2(CAN_InitStruct->CAN_BS2));assert_param(IS_CAN_PRESCALER(CAN_InitStruct->CAN_Prescaler));/*Exitfromsleepmode*/CANx->MCR&=(~(uint32_t)CAN_MCR_SLEEP);/*Requestinitialisation*/CANx->MCR|=CAN_MCR_INRQ;/*Waittheacknowledge*/while(((CANx->MSR&CAN_MSR_INAK)!=CAN_MSR_INAK)&&(wait_ack!=INAK_TIMEOUT)){wait_ack++;}/*Checkacknowledge*/if((CANx->MSR&CAN_MSR_INAK)!=CAN_MSR_INAK){InitStatus=CAN_InitStatus_Failed;=====================卡在这个位置}请教各位,有遇到过吗?麻烦指导下,谢谢大家!

  • 单周期乘法器和17周期分频器我要怎么去使用它?

    GD32E230系列的,里面描述的单周期乘法器和17周期分频器我要怎么去使用它?在哪里有详细的描述?

    嵌入式 单片机 GD32

    2024-12-10 13
  • GD32E230 串口1 PA2 PA3无法使用

    GD32E230的datasheet中可以看到PA2和PA3是可以复用到USART1的,然后使用官方的例程,将官方例程默认引进从串口0中的PA9、PA10可以打印。请教一下有没有人知道PA2、PA3怎么当串口1使用?以下是官方例程,我将引脚宏定义改成PA2和PA3,串口0也改为了串口1:usart.h文件#definePrint_GPIO_RCURCU_GPIOA//串口对应GPIO端口的时钟#definePrint_USART_RCURCU_USART1//对应串口号的时钟#definePrint_GPIOGPIOA//串口对应GPIO端口#definePrint_GPIO_AFGPIO_AF_1//串口是GPIO引脚的复用功能1(查询芯片数据手册)#definePrint_TX_PINGPIO_PIN_2//串口对应的GPIO引脚#definePrint_RX_PINGPIO_PIN_3//串口对应的GPIO引脚#definePrint_USARTUSART1//print所使用的串口1usart.c文件//串口打印初始化voidusart_print_init(void){usart_print_gpio_init();usart_print_config();}/*!\briefinitilizethecomGPIO\paramnone\param[out]none\retvalnone*/voidusart_print_gpio_init(void){/*enablePrintGPIOclock*/rcu_periph_clock_enable(Print_GPIO_RCU);/*connectporttoUSARTx_Tx*/gpio_af_set(Print_GPIO,Print_GPIO_AF,Print_TX_PIN);/*connectporttoUSARTx_Rx*/gpio_af_set(Print_GPIO,Print_GPIO_AF,Print_RX_PIN);/*configureUSARTTxasalternatefunctionpush-pull*/gpio_mode_set(Print_GPIO,GPIO_MODE_AF,GPIO_PUPD_PULLUP,Print_TX_PIN);gpio_mode_set(Print_GPIO,GPIO_MODE_AF,GPIO_PUPD_PULLUP,Print_RX_PIN);/*configureUSARTRxasalternatefunctionpush-pull*/gpio_output_options_set(Print_GPIO,GPIO_OTYPE_PP,GPIO_OSPEED_10MHZ,Print_TX_PIN);gpio_output_options_set(Print_GPIO,GPIO_OTYPE_PP,GPIO_OSPEED_10MHZ,Print_RX_PIN);}/*!\briefinitilizetheUSARTconfigurationofthecom\paramnone\param[out]none\retvalnone*/voidusart_print_config(void){/*enableUSARTclock*/rcu_periph_clock_enable(Print_USART_RCU);/*US

    GD32E230 串口 PA 使用 pi

    2024-11-14 10
  • vscode+GCC+Jlink烧录GD32程序时发生Writing target memory failed

    首次用vscode来烧录(国产化的需要),仿真器是ArmV9,芯片是GD32F103ZET6,烧录配置想用JlnkSWD,但是用USB连接pc和仿真器--GD开发板后,点击vscode中的烧录,出现如下错误:网上找了很多帖子还没有解决,有思路的请指点下,谢谢

  • 在用win10+vscode环境中用Jlink烧录gd32程序失败,求思路,谢谢

    出错信息如下:请大家看看有没有思路,谢谢。或者用vscode环境+Jlink烧录GD32的程序,是怎么个步骤烧录的?

    vscode GD32烧录 GD32 link win10

    2024-11-06 16
  • 英飞凌TLE9877使用Flash中的EEPROM写入数据

    英飞凌TLE9877如何使用Flash中的EEPROM写入数据,大概每次写入几个字节的数据内容,还要能读取出来,我要怎么实现呢。

  • HC32L196KCTA

    HC32L196KCTA深度休眠模式,任意IO口都可以唤醒吗

    IO L19 HC 单片机

    2024-08-16 4
  • 请问HC32F460和HC32F4A0的openocd官方有支持吗

    本帖最后由66ccff于2024-8-1208:34编辑我想在ubuntu上开发hc32,clion编译环境已经搭好了,但是hc32没有对应的openocd,无法下载调试有大佬指导一下吗

  • GigaDevice MCU 自己写bootloader烧录程序怎么写?

    GigaDeviceMCU想自己写bootloader烧录程序,不知道怎么写。请教各路大神。

  • GD32F103ZET6内部ADC2有没有

    使用官方的库函数,ADC2根本无法初始化dma_parameter_structdma_data_parameter;rcu_periph_clock_enable(RCU_GPIOF);rcu_periph_clock_enable(RCU_ADC2);rcu_periph_clock_enable(RCU_DMA1);/*配置PF*/gpio_init(GPIOF,GPIO_MODE_AIN,GPIO_OSPEED_50MHZ,GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10);/*ADCDMA_channelconfiguration*/dma_deinit(DMA1,DMA_CH4);/*initializeDMAsingledatamode*/dma_data_parameter.periph_addr=(uint32_t)(&ADC_RDATA(ADC2));dma_data_parameter.periph_inc=DMA_PERIPH_INCREASE_DISABLE;dma_data_parameter.memory_addr=(uint32_t)(&ADC2_ConvertedValue);dma_data_parameter.memory_inc=DMA_MEMORY_INCREASE_ENABLE;dma_data_parameter.periph_width=DMA_PERIPHERAL_WIDTH_16BIT;dma_data_parameter.memory_width=DMA_MEMORY_WIDTH_16BIT;dma_data_parameter.direction=DMA_PERIPHERAL_TO_MEMORY;dma_data_parameter.number=M1*N1;dma_data_parameter.priority=DMA_PRIORITY_HIGH;dma_init(DMA1,DMA_CH4,&dma_data_parameter);dma_circulation_enable(DMA1,DMA_CH4);/*enableDMAchannel*/dma_channel_enable(DMA1,DMA_CH4);/*ADC配置*/adc_deinit(ADC2);/*ADCmodeconfig*/adc_mode_config(ADC_MODE_FREE);/*ADCcontineousfunctionenable*/adc_special_function_config(ADC2,ADC_CONTINUOUS_MODE,ENABLE);/*ADCscanmodedisable*/adc_special_function_config(ADC2,ADC_SCAN_MODE,ENABLE);/*ADCdataalignmentconfig*/adc_data_alignment_config(ADC2,ADC_DATAALIGN_RIGHT);/*ADCchannellengthconfig*/adc_channel_length_config(ADC2,ADC_REGULAR_CHANNEL,M1);/*ADC0规则通道配置*/adc_regular_channel_config(ADC2,0,ADC_CHANNEL_7,ADC_SAMPLETIME_239POINT5);adc_regular_channel_config(ADC2,1,ADC_CHANNEL_8,ADC_SAMPLETIME_239POINT5);adc_regular_channel_config(ADC2,2,ADC_CHA

    ig DM ma DMA gd32f103zet6 ADC2

    2024-06-25 18
  • GD32E230, VREFINT居然每次复位都会变?

    以前用ADC很少用内部基准,都是尽量加一个431什么的,多用一个ADC通道读431再换算这次偷懒用了VREFINT,结果发现每次复位之后ADC采样结果相差挺大,于是单独把VREFINT的值输出到串口再换算成电压试试.一看吓一跳,标称1.2V,最低只有1.138V左右,最高1.207V左右,每次复位都不一样,复位之后倒是挺稳定的.是我哪里设置得不对吗?还是这东西就这样...

    2023-11-16 81
  • GD32L233低功耗模式下功耗1.8mA

    #if1voidlowpower_test(void){uint8_tcount=0;gpio_mode_set(GPIOA,GPIO_MODE_ANALOG,GPIO_PUPD_NONE,GPIO_PIN_ALL);gpio_mode_set(GPIOB,GPIO_MODE_ANALOG,GPIO_PUPD_NONE,GPIO_PIN_ALL);gpio_mode_set(GPIOC,GPIO_MODE_ANALOG,GPIO_PUPD_NONE,GPIO_PIN_ALL);gpio_mode_set(GPIOD,GPIO_MODE_ANALOG,GPIO_PUPD_NONE,GPIO_PIN_ALL);gpio_mode_set(GPIOF,GPIO_MODE_ANALOG,GPIO_PUPD_NONE,GPIO_PIN_ALL);#if0rcu_periph_clock_enable(RCU_GPIOC);gpio_mode_set(GPIOC,GPIO_MODE_OUTPUT,GPIO_PUPD_NONE,GPIO_PIN_7);gpio_mode_set(GPIOA,GPIO_MODE_INPUT,GPIO_PUPD_PULLUP,GPIO_PIN_0);//gpio_mode_set(GPIOA,GPIO_MODE_INPUT,GPIO_PUPD_NONE,GPIO_PIN_0);nvic_irq_enable(EXTI0_IRQn,2U);syscfg_exti_line_config(EXTI_SOURCE_GPIOA,EXTI_SOURCE_PIN0);exti_init(EXTI_0,EXTI_INTERRUPT,EXTI_TRIG_FALLING);exti_interrupt_flag_clear(EXTI_0);#endifwhile(1){/*code*///delay_1ms(500);delay(2000000);//gpio_bit_set(GPIOC,GPIO_PIN_7);//delay_1ms(500);delay(2000000);//gpio_bit_reset(GPIOC,GPIO_PIN_7);if(++count==5){count=0;//systick_enable(0);pmu_to_deepsleepmode(PMU_LDNPDSP_LOWDRIVE,WFI_CMD,PMU_DEEPSLEEP2);//systick_enable(1);}}}#endif/*!\briefmainfunction\paramnone\param[out]none\retvalnone*/intmain(void){//systick_config();#if1lowpower_test();#endif}供电3.3V,芯片外围IO引脚全部断开,所有的IO设置为模拟模式,实测电流1.8mA

    GD 低功耗

    2022-01-17 18
  • GD32F305VG timer0输入捕获无反应

    各位大佬好!我按照GD32F30x的标准库配置了GD32F305VG的timer0定时器并开启了输入捕获功能,配置代码如下:voidtimer_config(void){/*-----------------------------------------------------------------------timer_parameter_structtimer_initpara;timer_ic_parameter_structtimer_icinitpara;rcu_periph_clock_enable(RCU_TIMER0);timer_deinit(TIMER0);/*NVICconfig*/nvic_irq_enable(TIMER0_UP_TIMER9_IRQn,1,1);nvic_irq_enable(TIMER0_Channel_IRQn,1,0);/*TIMER0configuration*/timer_initpara.prescaler=119;timer_initpara.alignedmode=TIMER_COUNTER_EDGE;timer_initpara.counterdirection=TIMER_COUNTER_UP;timer_initpara.period=999;timer_initpara.clockdivision=TIMER_CKDIV_DIV1;timer_initpara.repetitioncounter=0;timer_init(TIMER0,&timer_initpara);timer_icinitpara.icpolarity=TIMER_IC_POLARITY_RISING;timer_icinitpara.icselection=TIMER_IC_SELECTION_DIRECTTI;timer_icinitpara.icprescaler=TIMER_IC_PSC_DIV1;timer_icinitpara.icfilter=0x0;timer_input_capture_config(TIMER0,TIMER_CH_0,&timer_icinitpara);timer_input_capture_config(TIMER0,TIMER_CH_3,&timer_icinitpara);/*auto-reloadpreloadenable*/timer_auto_reload_shadow_enable(TIMER0);timer_interrupt_flag_clear(TIMER0,TIMER_INT_FLAG_CH0);timer_interrupt_flag_clear(TIMER0,TIMER_INT_FLAG_CH3);timer_interrupt_enable(TIMER0,TIMER_INT_CH0);timer_interrupt_enable(TIMER0,TIMER_INT_CH3);timer_interrupt_enable(TIMER0,TIMER_INT_UP);timer_enable(TIMER0);}/*中断服务程序*/voidTIMER0_UP_TIMER9_IRQHandler(void){if(timer_interrupt_flag_get(TIMER0,TIMER_INT_FLAG_UP)!=RESET){timer_interrupt_flag_clear(TIMER0,TIMER_INT_FLAG_UP);timer0tick++;}}voidTIMER0_Channel_IRQHandler(){if(timer_interrupt