|
This post was last edited by yanxinboy on 2020-9-12 21:41
According to the test plan at the time of application, I am currently familiar with Qinheng's documents and the libraries provided, especially the operation of Bluetooth BLE and Ethernet. At the same time, I am doing simple tests on the common peripherals provided by CH579.
Since CH579 is based on the ARM M0 core, today's test will test the GPIO and GPIO external interrupts of CH579, using SYSTICK at the same time.
Test function: When the system is powered on, SYSTICK sets a 100MS interrupt, and the onboard LED3 and LED4 flash alternately at a 1S cycle through SYSTICK. After pressing the GPIO external interrupt button, LED3 and LED4 will flash alternately at a speed of 0.2 seconds. Press the external button again, and LED3 and LED4 will flash alternately at a 1S interval again. And so on.
Hardware connection: LED3 and LED4 are connected to PA0 and PB0 respectively (LED3 and LED4 of Qinheng CH579M-R1 development board are not connected to any GPIO, and are for users to choose to connect and use); the button uses the onboard button S2 (RESET - default GPIO function) connected to PA1 (S2 is originally connected to PB 23, and for the convenience of testing, directly connect PB23 and PA1 pins, because GPIO external interrupts are only provided in PA0~PA15, PB0~PB15)
Here is the program code directly, which is relatively simple and for testing purposes. Sorry for the poor writing:
#include "CH57x_common.h"
static unsigned char KeyS2status=0;
void DebugInit(void)
{
GPIOA_SetBits(GPIO_Pin_9);
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_ModeIN_PU);
GPIOA_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA);
UART1_DefInit();
}
void SysTick_Handler(void)
{
static unsigned char cnt=0;
if(!KeyS2status){
cnt++;
if(cnt>9){
cnt=0;
GPIOB_InverseBits(GPIO_Pin_0);
PRINT("LED4 Toggle every 1 second\r\n");
GPIOA_InverseBits(GPIO_Pin_0);
PRINT("LED3 Toggle every 1 second\r\n");
}
}
else{
cnt++;
if(cnt>1){
cnt=0;
GPIOB_InverseBits(GPIO_Pin_0);
PRINT("LED4 Toggle every 0.2 second\r\n");
GPIOA_InverseBits(GPIO_Pin_0);
PRINT("LED3 Toggle every 0.2 second\r\n");
}
}
}
void GPIO_IRQHandler(void)
{
KeyS2status=~KeyS2status;
GPIOA_ClearITFlagBit( GPIO_Pin_1 );
}
int main()
{
DebugInit();
PRINT( "Start @ChipID=%02X Test By Yanxinboy\n", R8_CHIP_ID );
GPIOB_SetBits(GPIO_Pin_0);
GPIOB_ModeCfg(GPIO_Pin_0,GPIO_ModeOut_PP_5mA);
GPIOB_ResetBits(GPIO_Pin_0);
GPIOA_SetBits(GPIO_Pin_0);
GPIOA_ModeCfg(GPIO_Pin_0,GPIO_ModeOut_PP_5mA);
SysTick_Config(FREQ_SYS/10);
GPIOA_ModeCfg( GPIO_Pin_1, GPIO_ModeIN_PU );
GPIOA_ITModeCfg( GPIO_Pin_1, GPIO_ITMode_FallEdge );
NVIC_EnableIRQ( GPIO_IRQn );
while(1){
;
}
}
 
The experimental phenomenon is shown in the video, and the serial port input and output are as follows:
|