问答

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

21ic问答首页 - TAG - GD
  • 有没有兆易代理商电话

    有没有兆易代理商电话 福州片区

    GD

    1265浏览量 2回复量 关注量
  • GD32F470ZG外部flash模拟U盘,每次插拔都要重新格式化?

    用的官方例程SRAM模拟U盘,官方的每次插拔不会掉格式,我改的外部flash,不清楚为什么每次插拔都要重新格式化,但是格式化后又能正常往里面放文件,读文件都是正常的 #define STORAGE_BLK_NBR 512 #define STORAGE_BLK_SIZ 4096 static int8_t STORAGE_Read (uint8_t Lun, uint8_t *buf, uint32_t BlkAddr, uint16_t BlkLen) { spi_flash_buffer_read(buf,BlkAddr*STORAGE_BLK_SIZ,BlkLen*STORAGE_BLK_SIZ); return 0; } /*! \brief write data to the medium \param[in] Lun: logical unit number \param[in] buf: pointer to the buffer to write \param[in] BlkAddr: address of 1st block to be written \param[in] BlkLen: number of blocks to be write \param[out] none \retval status */ static int8_t STORAGE_Write (uint8_t Lun, uint8_t *buf, uint32_t BlkAddr, uint16_t BlkLen) { //spi_flash_sector_erase(BlkAddr*STORAGE_BLK_SIZ); W25QXX_Write(buf, BlkAddr*STORAGE_BLK_SIZ, BlkLen*STORAGE_BLK_SIZ); return 0; } 并且我给2M,格式化前2M,格式化后变1.98了

    国产芯片 GD USB flash

    1515浏览量 2回复量 关注量
  • GD32F450II怎么在MDK5中进行软件仿真?

    如题,使用MDK自带的软件仿真功能时,一直卡在时钟起振完成那里,这个需要设置啥吗?还是说这个系列暂时不知道软件仿真?

    MCU GD GD32F450 MDK 软件仿真

    4832浏览量 19回复量 关注量
  • 求助爱分享的韩小明 sos

    gd32f450xx的开发手册上有个start-up time 143ms左右,请问为什么会有这个时延?这段时间是在锁PLL还是在干啥? 使用逻分分别测试了gd32和stm32f4xx系列,gd系列确实有140ms多的延时,但stm32f4xx系列就没有该延时。 请问有没有时延水平和stm32一致的gd32系列?

    GD

    1128浏览量 0回复量 关注量
  • GD32E503RC进入用户程序区以后初始化Systick,无法进入中断 sos

    GD32E503RC通过IAP以后进入用户程序区以后初始化Systick,开启中断以后无法进入SysTick_Handler中断,在更新程序区则能正常进入Systick中断。请问是有什么地方需要特殊设置的吗。 void systick_config(void) { /* setup systick timer for 1000Hz interrupts */ if(SysTick_Config(SystemCoreClock / 1000U)){ /* capture error */ while(1){ } } /* configure the systick handler priority */ NVIC_SetPriority(SysTick_IRQn, 0x00U); }

    GD GD32E systick rc CONFIG ig

    1855浏览量 0回复量 关注量
  • GD32F450ZIT6使用JFlash工具无法擦除芯片,程序超过1M就无法下载

    GD32F450ZIT6使用JFlash工具无法擦除芯片,前1M的Flash空间可以擦除,后面1M空间擦除失败,有使用这款芯片遇到类似的问题吗。用IAR仿真器可以将APP程序下载进去,用Jflash工具就下载不了,App程序大小大概占用了1.5M的flash。

    GD 国产芯片 单片机 MCU 使用 芯片

    1330浏览量 1回复量 关注量
  • GD32 SPI+DMA 发送不了数据

    我是从STM32F103VCT6的代码移植到GD32F103VCT6,代码在STM32上跑的没问题,产品都上市了,现在移植过来,如题所述。我要实现的功能也就是基于SPI+DMA去控制SK6812灯带,实际跑下来DMA无法发送数据,调试时,DMA_GetFlagStatus(DMA1_FLAG_TC5)==0,始终为0,也就是DMA发送完成标志始终不置1,不知道为啥,看寄存器相关配置都没问题,但一个数据都发不出来。 代码如下: void LED_SPI_LowLevel_Init(void) { uint16_t i = 0; uint32_t temp =0; GPIO_InitTypeDef GPIO_InitStructure; SPI_InitTypeDef SPI_InitStructure; DMA_InitTypeDef DMA_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); DMA_Cmd(DMA1_Channel5, DISABLE); DMA_DeInit(DMA1_Channel5); DMA_InitStructure.DMA_BufferSize = 0; //开辟3个连续的DMA存储单元 // DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) & (SPI2->DR); //外设地址(u32)SPI2_DR_Address; DMA_InitStructure.DMA_PeripheralBaseAddr = 0x4000380C; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)PixelBuffer; //内存地址,就是你想要把采样值存在那个变量的地址 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; //方向 DMA_InitStructure.DMA_Priority = DMA_Priority_Low; //DMA优先级为低 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址不变 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //内存地址自增 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //设置外设数据长度为半字,即16位 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //设置DMA存储数据长度为半字,即16位 DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_Init(DMA1_Channel5 , &DMA_InitStructure); /* DMA1 CH3 = MEM -> DR */ DMA_SetCurrDataCounter(DMA1_Channel5, 0); temp=GPIOB->CRH; temp&=0x0fffffff; temp|=0xb0000000; GPIOB->CRH=temp; // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //PB15 RGB // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // GPIO_Init(GPIOB, &GPIO_InitStructure); /* GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_Init(GPIOA, &GPIO_InitStructure); */ SPI_I2S_DeInit(SPI2); SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; //* 72MHz / 8 =9MHz / 16bit*/ SPI2在低速时钟,SPI1在高速时钟 SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI2, &SPI_InitStructure); SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, ENABLE); SPI_Cmd(SPI2, ENABLE); for (i = 0; i < 2190; i++) {PixelBuffer[i] = 0xf0;} PixelPointer = 0; } uint8_t SK6812_light(unsigned long light, uint32_t length,HARDWARE_PARAMS_S *hardware_params) { uint16_t i = 0; uint8_t send_result = 0; // static uint16_t last_send_DMA = 0; // uint16_t last_send_DMA_past = 0; switch (hardware_params ->light.light_mod) { case 0 : if(SystemTime_Cnt>=hardware_params ->light.last_send_DMA) hardware_params ->light.last_send_DMA_past = SystemTime_Cnt-hardware_params ->light.last_send_DMA; else hardware_params ->light.last_send_DMA_past = 60000-hardware_params ->light.last_send_DMA + SystemTime_Cnt; left_data=DMA_GetCurrDataCounter(DMA1_Channel5); if(left_data == 0) { for (i = 0; i < length; i++) { LED_SPI_SendPixel(light);//数据存到数组内存中 } PixelPointer = 0; DMA_InitTypeDef DMA_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); DMA_Cmd(DMA1_Channel5, DISABLE); DMA_DeInit(DMA1_Channel5); DMA_InitStructure.DMA_BufferSize = 24*length; // DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) & (SPI2->DR); DMA_InitStructure.DMA_PeripheralBaseAddr = 0x4000380C; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)PixelBuffer; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //DMA_MemoryInc_Enable DMA_MemoryInc_Disable DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; //DMA ?? x ?????? DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; // ???????? DMA_Init(DMA1_Channel5, &DMA_InitStructure); DMA_Cmd(DMA1_Channel5, DISABLE); DMA_ClearFlag(DMA1_FLAG_TC5); DMA_SetCurrDataCounter(DMA1_Channel5, (24*length));//80 1940 ok DMA_Cmd(DMA1_Channel5, ENABLE); hardware_params ->light.last_send_DMA = SystemTime_Cnt; hardware_params ->light.light_mod = 1; } else if(hardware_params ->light.last_send_DMA_past>3000) { hardware_params ->light.light_mod = 2; WLOG_INFO("left_data=%d\n",left_data); } break; case 1: if(SystemTime_Cnt>=hardware_params ->light.last_send_DMA)hardware_params ->light.last_send_DMA_past = SystemTime_Cnt-hardware_params ->light.last_send_DMA; else hardware_params ->light.last_send_DMA_past = 60000-hardware_params ->light.last_send_DMA + SystemTime_Cnt; send_result = wait_DMA_send(); if(send_result) { left_data=DMA_GetCurrDataCounter(DMA1_Channel5); hardware_params ->light.light_mod = 0; } else { if(hardware_params ->light.last_send_DMA_past>500) { hardware_params ->light.light_mod = 2; left_data=DMA_GetCurrDataCounter(DMA1_Channel5); WLOG_INFO("left_data1=%d\n",left_data); } } break; case 2: LED_SPI_LowLevel_Init(); send_result = 1; hardware_params ->light.last_send_DMA = SystemTime_Cnt; hardware_params ->light.light_mod = 0; // WLOG_INFO("last_send_DMA_past=%d\n",hardware_params ->light.last_send_DMA_past); break; default: break; } return send_result; } /* uint8_t SK6812_light(unsigned long light, uint32_t length) { uint16_t i = 0; static uint8_t light_mod = 0; uint8_t send_result = 0; switch (light_mod) { case 0 : left_data=DMA_GetCurrDataCounter(DMA1_Channel3); if(left_data == 0) { for (i = 0; i < length; i++) { LED_SPI_SendPixel(light); } PixelPointer = 0; DMA_InitTypeDef DMA_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); DMA_DeInit(DMA1_Channel3); DMA_InitStructure.DMA_BufferSize = 24*length; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) & (SPI1->DR); DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)PixelBuffer; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //DMA_MemoryInc_Enable DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_Init(DMA1_Channel3, &DMA_InitStructure); DMA_Cmd(DMA1_Channel3, DISABLE); DMA_ClearFlag(DMA1_FLAG_TC3); DMA_SetCurrDataCounter(DMA1_Channel3, (24*length));//80 1940 ok DMA_Cmd(DMA1_Channel3, ENABLE); light_mod = 1; } break; case 1: send_result = wait_DMA_send(); if(send_result)light_mod = 0; break; default: break; } return send_result; }*/ uint8_t wait_DMA_send(void) { uint8_t send_result =0; if(DMA_GetFlagStatus(DMA1_FLAG_TC5)==0) { left_data=DMA_GetCurrDataCounter(DMA1_Channel5); dma_error = DMA_GetFlagStatus(DMA1_FLAG_TE5); send_result = 0; // WLOG_INFO("left_data1=%d\n",left_data); // LED_SPI_LowLevel_Init(); } if(DMA_GetFlagStatus(DMA1_FLAG_TC5)==1) { left_data=DMA_GetCurrDataCounter(DMA1_Channel5); if(left_data) { WLOG_INFO("left_data1=%d\n",left_data); } DMA_Cmd(DMA1_Channel5, DISABLE); // disable DMA channel 6 DMA_ClearFlag(DMA1_FLAG_TC5); // clear DMA1 Channel 6 transfer complete flag DMA_SetCurrDataCounter(DMA1_Channel5, 0); send_result = 1; left_data = 0; } return send_result; }

    国产芯片 GD spi DMA

    1176浏览量 2回复量 关注量
  • GD32F103C8T6/CBT6和ST芯片如何识别

    GD32F103C8T6/CBT6和ST芯片可以通过标志位来识别吗,看到有些方法,但不确认是不是可靠的,有用过的大佬支持下哈

    ST GD

    7591浏览量 4回复量 关注量
  • GD32F103VET6移植STM的API,引脚操作比GD的API慢

    按要求修改了flash启动时间,时钟频率为72MHZ,分频方式也是按照GD库的分频强制分的72MHZ,但就是GUI刷屏显示明显慢,但使用GD的API则正常。对比过RCC配置寄存器及引脚配置寄存器,配置的内容是一样的

    GD ST API 移植 gd32F103 STM

    1221浏览量 1回复量 关注量
  • GD32L233低功耗模式下功耗1.8mA

    [color=#d4d4d4][backcolor=#1e1e1e][font=Consolas,][color=#c586c0]#if[/color][color=#569cd6] [/color][color=#b5cea8]1[/color] [color=#569cd6]void[/color][color=#d4d4d4] [/color][color=#dcdcaa]lowpower_test[/color][color=#d4d4d4]([/color][color=#569cd6]void[/color][color=#d4d4d4])[/color] [color=#d4d4d4]{[/color] [color=#d4d4d4] [/color][color=#4ec9b0]uint8_t[/color][color=#d4d4d4] [/color][color=#9cdcfe]count[/color][color=#d4d4d4]=[/color][color=#b5cea8]0[/color][color=#d4d4d4];[/color] [color=#d4d4d4] [/color][color=#dcdcaa]gpio_mode_set[/color][color=#d4d4d4]([/color][color=#569cd6]GPIOA[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_MODE_ANALOG[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PUPD_NONE[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PIN_ALL[/color][color=#d4d4d4]);[/color] [color=#d4d4d4] [/color][color=#dcdcaa]gpio_mode_set[/color][color=#d4d4d4]([/color][color=#569cd6]GPIOB[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_MODE_ANALOG[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PUPD_NONE[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PIN_ALL[/color][color=#d4d4d4]);[/color] [color=#d4d4d4] [/color][color=#dcdcaa]gpio_mode_set[/color][color=#d4d4d4]([/color][color=#569cd6]GPIOC[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_MODE_ANALOG[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PUPD_NONE[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PIN_ALL[/color][color=#d4d4d4]);[/color] [color=#d4d4d4] [/color][color=#dcdcaa]gpio_mode_set[/color][color=#d4d4d4]([/color][color=#569cd6]GPIOD[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_MODE_ANALOG[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PUPD_NONE[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PIN_ALL[/color][color=#d4d4d4]);[/color] [color=#d4d4d4] [/color][color=#dcdcaa]gpio_mode_set[/color][color=#d4d4d4]([/color][color=#569cd6]GPIOF[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_MODE_ANALOG[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PUPD_NONE[/color][color=#d4d4d4],[/color][color=#569cd6]GPIO_PIN_ALL[/color][color=#d4d4d4]);[/color] [color=#569cd6] [/color][color=#c586c0]#if[/color][color=#569cd6] [/color][color=#b5cea8]0[/color] [color=#6a9955] rcu_periph_clock_enable(RCU_GPIOC);[/color] [color=#6a9955] gpio_mode_set(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_7);[/color] [color=#6a9955] gpio_mode_set(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO_PIN_0);[/color] [color=#6a9955] // gpio_mode_set(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO_PIN_0);[/color] [color=#6a9955] nvic_irq_enable(EXTI0_IRQn, 2U);[/color] [color=#6a9955] syscfg_exti_line_config(EXTI_SOURCE_GPIOA, EXTI_SOURCE_PIN0);[/color] [color=#6a9955] exti_init(EXTI_0, EXTI_INTERRUPT, EXTI_TRIG_FALLING);[/color] [color=#6a9955] exti_interrupt_flag_clear(EXTI_0);[/color] [color=#569cd6] [/color][color=#c586c0]#endif[/color] [color=#d4d4d4] [/color][color=#c586c0]while[/color][color=#d4d4d4]([/color][color=#b5cea8]1[/color][color=#d4d4d4])[/color] [color=#d4d4d4] {[/color] [color=#d4d4d4] [/color][color=#6a9955]/* code */[/color] [color=#d4d4d4] [/color][color=#6a9955]// delay_1ms(500);[/color] [color=#d4d4d4] [/color][color=#dcdcaa]delay[/color][color=#d4d4d4]([/color][color=#b5cea8]2000000[/color][color=#d4d4d4]);[/color] [color=#d4d4d4] [/color][color=#6a9955]// gpio_bit_set(GPIOC, GPIO_PIN_7);[/color] [color=#d4d4d4] [/color][color=#6a9955]// delay_1ms(500);[/color] [color=#d4d4d4] [/color][color=#dcdcaa]delay[/color][color=#d4d4d4]([/color][color=#b5cea8]2000000[/color][color=#d4d4d4]);[/color] [color=#d4d4d4] [/color][color=#6a9955]// gpio_bit_reset(GPIOC, GPIO_PIN_7);[/color] [color=#d4d4d4] [/color][color=#c586c0]if[/color][color=#d4d4d4](++[/color][color=#9cdcfe]count[/color][color=#d4d4d4] == [/color][color=#b5cea8]5[/color][color=#d4d4d4]){[/color] [color=#d4d4d4] [/color][color=#9cdcfe]count[/color][color=#d4d4d4] = [/color][color=#b5cea8]0[/color][color=#d4d4d4];[/color] [color=#d4d4d4] [/color][color=#6a9955]// systick_enable(0);[/color] [color=#d4d4d4] [/color][color=#dcdcaa]pmu_to_deepsleepmode[/color][color=#d4d4d4]([/color][color=#569cd6]PMU_LDNPDSP_LOWDRIVE[/color][color=#d4d4d4], [/color][color=#569cd6]WFI_CMD[/color][color=#d4d4d4], [/color][color=#569cd6]PMU_DEEPSLEEP2[/color][color=#d4d4d4]);[/color] [color=#d4d4d4] [/color][color=#6a9955]// systick_enable(1);[/color] [color=#d4d4d4] }[/color] [color=#d4d4d4] }[/color] [color=#d4d4d4]}[/color] [color=#c586c0]#endif[/color] [color=#6a9955]/*![/color] [color=#6a9955] [/color][color=#569cd6]\brief[/color][color=#6a9955] main function[/color] [color=#6a9955] [/color][color=#569cd6]\param[/color][color=#6a9955][[/color][color=#569cd6]in[/color][color=#6a9955]] [/color][color=#9cdcfe]none[/color] [color=#6a9955] [/color][color=#569cd6]\param[/color][color=#6a9955][[/color][color=#569cd6]out[/color][color=#6a9955]] [/color][color=#9cdcfe]none[/color] [color=#6a9955] [/color][color=#569cd6]\retval[/color][color=#6a9955] none[/color] [color=#6a9955]*/[/color] [color=#569cd6]int[/color][color=#d4d4d4] [/color][color=#dcdcaa]main[/color][color=#d4d4d4]([/color][color=#569cd6]void[/color][color=#d4d4d4])[/color] [color=#d4d4d4]{[/color] [color=#d4d4d4] [/color][color=#6a9955]// systick_config();[/color] [color=#569cd6] [/color][color=#c586c0]#if[/color][color=#569cd6] [/color][color=#b5cea8]1[/color] [color=#d4d4d4] [/color][color=#dcdcaa]lowpower_test[/color][color=#d4d4d4]();[/color] [color=#569cd6] [/color][color=#c586c0]#endif[/color] [color=#c586c0]} [/color] [/font][/backcolor][/color] 供电3.3V,芯片外围IO引脚全部断开,所有的IO设置为模拟模式,实测电流1.8mA

    GD 低功耗

    6977浏览量 17回复量 关注量
  • GD32F103C8T6 CAN没有输出

    GD32F103C8T6 CAN没有输出 回环模式,可以读取回数据,但是我重映射的PB8,PB9没有信号出来,外接的TJA1050,请问有遇到类似问题的吗? 代码如下 can_trasnmit_message_struct transmit_message; can_receive_message_struct receive_message; uint8_t CAN_Tx_Buf[8]; uint8_t CAN_Rx_Buf[8]; /*! \brief initialize CAN and filter \param[in] can_parameter \arg can_parameter_struct \param[in] can_filter \arg can_filter_parameter_struct \param[out] none \retval none */ void BSP_CANInit(void) { can_parameter_struct can_parameter; can_filter_parameter_struct can_filter; /* configure CAN0 NVIC */ nvic_irq_enable(USBD_LP_CAN0_RX0_IRQn,1,2); /* enable CAN clock */ rcu_periph_clock_enable(RCU_CAN0); rcu_periph_clock_enable(RCU_GPIOB); rcu_periph_clock_enable(RCU_AF); /* configure CAN0 GPIO */ gpio_pin_remap_config(GPIO_CAN_FULL_REMAP,ENABLE); gpio_init(GPIOB,GPIO_MODE_IPU,GPIO_OSPEED_50MHZ,GPIO_PIN_8); gpio_init(GPIOB,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_9); /* initialize CAN and filter */ can_struct_para_init(CAN_INIT_STRUCT, &can_parameter); can_struct_para_init(CAN_FILTER_STRUCT, &can_filter); /* initialize CAN register */ can_deinit(CAN0); /* initialize CAN parameters */ can_parameter.time_triggered = DISABLE; //TTC 时间触发通信 0: 禁用时间触发通信 1: 使能时间触发通信 can_parameter.auto_bus_off_recovery = DISABLE; //ABOR 自动离线恢复 0: 通过软件手动地从离线状态恢复 1: 通过硬件自动的从离线状态恢复 can_parameter.auto_wake_up = DISABLE; //AWK 自动唤醒 0: 通过软件手动的从睡眠工作模式唤醒 1: 通过硬件自动的从睡眠工作模式唤醒 can_parameter.no_auto_retrans = ENABLE;//DISABLE; //ARD 自动重发禁止 0: 使能自动重发 1: 禁用自动重发 can_parameter.rec_fifo_overwrite = DISABLE; //RFOD 禁用接收FIFO满时覆盖 0: 使能接收FIFO满时覆盖 1: 禁用接收FIFO满时覆盖 can_parameter.trans_fifo_order = DISABLE; //TFO 发送FIFO顺序 0: 标识符(Identifier)较小的帧先发送 1: 所有等待发送的邮箱按照先进先出(FIFO)的顺序发送 #ifdef TEST_LOOPBACK can_parameter.working_mode = CAN_LOOPBACK_MODE; //回环模式 #else can_parameter.working_mode = CAN_NORMAL_MODE; //通信模式 #endif can_parameter.resync_jump_width = CAN_BT_SJW_1TQ; //SJW[1:0] 再同步补偿宽度 再同步补偿占用的时间单元数量= SJW[1:0]+1 can_parameter.time_segment_1 = CAN_BT_BS1_6TQ; //BS1[3:0] 位段1 位段1占用的时间单元数量=BS1[3:0]+1 can_parameter.time_segment_2 = CAN_BT_BS2_5TQ; //BS2[2:0] 位段2 位段2占用的时间单元数量=BS2[2:0]+1 can_parameter.prescaler = 6000 / CAN_BAUDRATE; //BRP[9:0] 波特率分频系数 /* initialize CAN */ can_init(CAN0, &can_parameter); /* CAN0 initialize filter */ can_filter.filter_number = 0; //disable filter // can_filter.filter_mode = CAN_FILTERMODE_LIST; //FMx 过滤器模式 0: 掩码模式 1: 列表模式 can_filter.filter_mode = CAN_FILTERMODE_MASK; //FMx 过滤器模式 0: 掩码模式 1: 列表模式 can_filter.filter_bits = CAN_FILTERBITS_32BIT; //FSx 过滤器位宽 0: 16-bit位宽 1: 32-bit位宽 can_filter.filter_list_high = FILTER_LIST_HIGH; //FDx 过滤器数据 can_filter.filter_list_low = FILTER_LIST_LOW; //FDx 过滤器数据 //列表模式下: //0: 标识符的Bit(x)必须为0 //1: 标识符的Bit(x)必须为1 can_filter.filter_mask_high = FILTER_MASK_HIGH; //FDx 过滤器数据 can_filter.filter_mask_low = FILTER_MASK_LOW; //FDx 过滤器数据 //掩码模式下: //0: 标识符的Bit(x)不需参与比较 //1: 标识符的Bit(x)需要参与比较 can_filter.filter_fifo_number = CAN_FIFO0; //FAFx 过滤器关联FIFO 0: 关联FIFO0 1: 关联FIFO1 can_filter.filter_enable = ENABLE; //FWx 过滤器激活 0: 没有激活 1: 激活工作 can_filter_init(&can_filter); /* enable can receive FIFO0 not empty interrupt */ can_interrupt_enable(CAN0, CAN_INTEN_RFNEIE0); } void CAN_process(void)//测试 1秒定时调用 { CAN_Tx_Buf[0] = 0x55; CAN_Tx_Buf[1] = 0xAA; CAN_Tx_Buf[2] = 0x01; CAN_Tx_Buf[3] = 0x02; CAN_Tx_Buf[4] = 0x03; CAN_Tx_Buf[5] = 0x04; CAN_Tx_Buf[6] = 0x05; CAN_Tx_Buf[7] = 0x06; BSP_CANWrite(CAN0, CAN_Tx_Buf); } void BSP_CANWrite(uint32_t can_periph, uint8_t *buff) { uint8_t i; #ifdef TEST_LOOPBACK uint32_t timeout = 0xFFFF; uint8_t transmit_mailbox = 0; #endif for (i = 0; i < 8; i++) { transmit_message.tx_data[i] = buff[i]; } /* initialize transmit message */ transmit_message.tx_sfid = TX_SFID; //SFID[10:0]/EFID[28:18] 标识符 //STID[10:0]: 标准格式帧标识符 //EXID[28:18]: 扩展格式帧标识符 transmit_message.tx_efid = TX_EFID; //EFID[17:0]: 扩展格式帧标识符 transmit_message.tx_ft = CAN_FT_DATA; //FT 帧种类 0: 数据帧 1: 遥控帧 // transmit_message.tx_ff = CAN_FF_STANDARD; //FF 帧格式 0: 标准格式帧 1: 扩展格式帧 transmit_message.tx_ff = CAN_FF_EXTENDED; //FF 帧格式 0: 标准格式帧 1: 扩展格式帧 transmit_message.tx_dlen = TX_DLEN; //DLC[3:0] 数据长度 #ifndef TEST_LOOPBACK /* transmit message */ can_message_transmit(can_periph, &transmit_message); #else /* transmit message */ transmit_mailbox = can_message_transmit(can_periph, &transmit_message); /* waiting for transmit completed */ while((CAN_TRANSMIT_OK != can_transmit_states(can_periph, transmit_mailbox)) && (0 != timeout)){ timeout--; } timeout = 0xFFFF; /* waiting for receive completed */ while((can_receive_message_length_get(can_periph, CAN_FIFO0) < (TX_DLEN - 1)) && (0 != timeout)){ timeout--; } /* initialize receive message*/ receive_message.rx_sfid = 0x00; receive_message.rx_ff = 0; receive_message.rx_dlen = 0; receive_message.rx_data[0] = 0x00; receive_message.rx_data[1] = 0x00; receive_message.rx_data[2] = 0x00; receive_message.rx_data[3] = 0x00; receive_message.rx_data[4] = 0x00; receive_message.rx_data[5] = 0x00; receive_message.rx_data[6] = 0x00; receive_message.rx_data[7] = 0x00; can_message_receive(CAN0, CAN_FIFO0, &receive_message); for(i = 0; i < TX_DLEN; i++) { System.com.can_rx[i] = receive_message.rx_data[i]; } CAN_TO_USART(COM_RS422); #endif } /*! \brief this function handles CAN0 RX0 exception \param[in] none \param[out] none \retval none */ void CAN0_RX0_IRQHandler(void) { uint8_t i; gd_eval_led_toggle(); /* check the receive message */ can_message_receive(CAN0, CAN_FIFO0, &receive_message); // if((TX_SFID == receive_message.rx_sfid) && (CAN_FF_STANDARD == receive_message.rx_ff) && (TX_DLEN == receive_message.rx_dlen)) if((TX_EFID == receive_message.rx_efid) && (CAN_FF_EXTENDED == receive_message.rx_ff) && (TX_DLEN == receive_message.rx_dlen)) { for(i = 0; i < TX_DLEN; i++) { System.com.can_rx[i] = receive_message.rx_data[i]; } CAN_TO_USART(COM_RS422); }else{ } }

    GD CAN 重映射 gd32f103c8t6 输出

    4175浏览量 1回复量 关注量
  • GD32F105VCT6 的USB作为device使用时,VBUS必须要接外部5V吗?

    GD32F105VCT6作为device使用,引出D+、D-在装置内部通过排线与其它板卡的Host相连接。GD32F105VCT6的板卡与其它板卡共用5V电源,板卡上分别转3.3V使用。 请问: (1)VBUS必须要接外部5V吗? (2)使用时还有其它要注意的吗?

    GD 技术交流 Device gd32f105vct6 USB 板卡

    1276浏览量 1回复量 关注量
  • 运行中途能否切换时钟源的问题

    新项目需要休眠,因为采用外接高速时钟比较精准,但是休眠后无法自唤醒,所以考虑在休眠前先切换到RC振荡器,唤醒后再切回来,是否可行?看了寄存器资料,说是时钟源选择后,除非复位备份寄存器否则无法更改?复位了原有的RTC不就重置了么?

    GD RTC 时钟 寄存器 rc RC振荡

    1572浏览量 3回复量 关注量
  • GD32F103RCT6 SPI0读25Q64,都是0xff

    在使用GD32F103做一个项目时,读出的23Q64的ID值,都是0xff.

    国产 GD SPI0

    4703浏览量 1回复量 关注量