/** * File Name : main.c * Author : Sherm * Version : V1.0.0 * Date : 2025/11/22 * Description : A4M6 testing**/
#include "debug.h"
void GPIOConfig(){ GPIO_InitTypeDef GPIO_InitStructure = {0};
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC , ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; //Apply the settings on all pins under the selected port GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //Internal pull-up -> Contributes to power saving
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //PC1 - LED pin GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //Push-pull ("toggleable") configuration GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //Lowest speed GPIO_Init(GPIOC, &GPIO_InitStructure);}
int main(void){ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); SystemCoreClockUpdate(); Delay_Init(); GPIOConfig(); //Configure the GPIOs -> All IPUs + 1 GPIO for the LED for(u8 i=0;i<6;i++){ GPIO_WriteBit(GPIOC, GPIO_Pin_0, Bit_SET); Delay_Ms(50); GPIO_WriteBit(GPIOC, GPIO_Pin_0, Bit_RESET); Delay_Ms(50); }
while(1) { //GPIO_WriteBit(GPIOC, GPIO_Pin_0, Bit_SET); GPIOC->BSHR = GPIO_Pin_0; //definitly faster then the GPIO_WriteBit func.. by 4x+ //Delay_Ms(200); //GPIO_WriteBit(GPIOC, GPIO_Pin_0, Bit_RESET); GPIOC->BCR = GPIO_Pin_0;/* Delay_Ms(200); GPIO_WriteBit(GPIOC, GPIO_Pin_1, Bit_SET); Delay_Ms(3000); //Wait 3 seconds GPIO_WriteBit(GPIOC, GPIO_Pin_1, Bit_RESET); */
}}
Put system_ch32v00x.c clock on internal speeds. All speeds tested(see CH32v300 page).