/******************************AT32F403AVGT7*************************************/
/******************************QQ774145445***************************************/
/******************************快手:共同学习stm8*********************************/
/******************************keil_mdk******************************************/
/********************************************************************************/
#define bit0 0b00000000000000000000000000000001
#define bit1 0b00000000000000000000000000000010
#define bit2 0b00000000000000000000000000000100
#define bit3 0b00000000000000000000000000001000
#define bit4 0b00000000000000000000000000010000
#define bit5 0b00000000000000000000000000100000
#define bit6 0b00000000000000000000000001000000
#define bit7 0b00000000000000000000000010000000
#define bit8 0b00000000000000000000000100000000
#define bit9 0b00000000000000000000001000000000
#define bit10 0b00000000000000000000010000000000
#define bit11 0b00000000000000000000100000000000
#define bit12 0b00000000000000000001000000000000
#define bit13 0b00000000000000000010000000000000
#define bit14 0b00000000000000000100000000000000
#define bit15 0b00000000000000001000000000000000
#define bit16 0b00000000000000010000000000000000
#define bit17 0b00000000000000100000000000000000
#define bit18 0b00000000000001000000000000000000
#define bit19 0b00000000000010000000000000000000
#define bit20 0b00000000000100000000000000000000
#define bit21 0b00000000001000000000000000000000
#define bit22 0b00000000010000000000000000000000
#define bit23 0b00000000100000000000000000000000
#define bit24 0b00000001000000000000000000000000
#define bit25 0b00000010000000000000000000000000
#define bit26 0b00000100000000000000000000000000
#define bit27 0b00001000000000000000000000000000
#define bit28 0b00010000000000000000000000000000
#define bit29 0b00100000000000000000000000000000
#define bit30 0b01000000000000000000000000000000
#define bit31 0b10000000000000000000000000000000
/********************************************************************************/ //指针定义
//#define GPIOA_DATA (*(volatile unsigned int*)(0x40011200+0x0000))
//#define (*(volatile unsigned int*)(0x4002 1000+0x0000))
/********************************************************************************/ //CRM寄存器
//4.3 CRM 寄存器
//寄存器简称 基址偏移量 复位值
//CRM_CTRL 0x000 0x0000 XX83
//CRM_CFG 0x004 0x0000 0000
//CRM_CLKINT 0x008 0x0000 0000
//CRM_APB2RST 0x00C 0x0000 0000
//CRM_APB1RST 0x010 0x0000 0000
//CRM_AHBEN 0x014 0x0000 0014
//CRM_APB2EN 0x018 0x0000 0000
//CRM_APB1EN 0x01C 0x0000 0000
//CRM_BPDC 0x020 0x0000 0000
//CRM_CTRLSTS 0x024 0x0C00 0000
//CRM_AHBRST 0x028 0x0000 0000
//CRM_MISC1 0x030 0x0000 0000
//CRM_MISC2 0x050 0x0000 0000
//CRM_MISC3 0x054 0x0000 000D
//CRM_INTMAP 0x05C 0x0000 0000
#define CRM_CTRL (*(volatile unsigned int*)(0x40021000+0x00))
#define CRM_CFG (*(volatile unsigned int*)(0x40021000+0x04))
#define CRM_CLKINT (*(volatile unsigned int*)(0x40021000+0x08))
#define CRM_APB2RST (*(volatile unsigned int*)(0x40021000+0x0C))
#define CRM_APB1RST (*(volatile unsigned int*)(0x40021000+0x10))
#define CRM_AHBEN (*(volatile unsigned int*)(0x40021000+0x14))
#define CRM_APB2EN (*(volatile unsigned int*)(0x40021000+0x18))
#define CRM_APB1EN (*(volatile unsigned int*)(0x40021000+0x1C))
#define CRM_BPDC (*(volatile unsigned int*)(0x40021000+0x20))
#define CRM_CTRLSTS (*(volatile unsigned int*)(0x40021000+0x24))
#define CRM_AHBRST (*(volatile unsigned int*)(0x40021000+0x28))
#define CRM_MISC1 (*(volatile unsigned int*)(0x40021000+0x30))
#define CRM_MISC2 (*(volatile unsigned int*)(0x40021000+0x50))
#define CRM_MISC3 (*(volatile unsigned int*)(0x40021000+0x54))
#define CRM_INTMAP (*(volatile unsigned int*)(0x40021000+0x5C))
/********************************************************************************/
/********************************************************************************/ //GPIO寄存器
//6.3 GPIO 寄存器
//寄存器简称 基址偏移量 复位值
//GPIOx_CFGLR 0x00 0x4444 4444
//GPIOx_CFGHR 0x04 0x4444 4444
//GPIOx_IDT 0x08 0x0000 XXXX
//GPIOx_ODT 0x0C 0x0000 0000
//GPIOx_SCR 0x10 0x0000 0000
//GPIOx_CLR 0x14 0x0000 0000
//GPIOx_WPR 0x18 0x0000 0000
//GPIOx_HDRV 0x3C 0x0000 0000
#define GPIOA_CFGLR (*(volatile unsigned int*)(0x40010800+0x00))
#define GPIOA_CFGHR (*(volatile unsigned int*)(0x40010800+0x04))
#define GPIOA_IDT (*(volatile unsigned int*)(0x40010800+0x08))
#define GPIOA_ODT (*(volatile unsigned int*)(0x40010800+0x0C))
#define GPIOA_SCR (*(volatile unsigned int*)(0x40010800+0x10))
#define GPIOA_CLR (*(volatile unsigned int*)(0x40010800+0x14))
#define GPIOA_WPR (*(volatile unsigned int*)(0x40010800+0x18))
#define GPIOA_HDRV (*(volatile unsigned int*)(0x40010800+0x3C))
#define GPIOB_CFGLR (*(volatile unsigned int*)(0x40010C00+0x00))
#define GPIOB_CFGHR (*(volatile unsigned int*)(0x40010C00+0x04))
#define GPIOB_IDT (*(volatile unsigned int*)(0x40010C00+0x08))
#define GPIOB_ODT (*(volatile unsigned int*)(0x40010C00+0x0C))
#define GPIOB_SCR (*(volatile unsigned int*)(0x40010C00+0x10))
#define GPIOB_CLR (*(volatile unsigned int*)(0x40010C00+0x14))
#define GPIOB_WPR (*(volatile unsigned int*)(0x40010C00+0x18))
#define GPIOB_HDRV (*(volatile unsigned int*)(0x40010C00+0x3C))
#define GPIOC_CFGLR (*(volatile unsigned int*)(0x40011000+0x00))
#define GPIOC_CFGHR (*(volatile unsigned int*)(0x40011000+0x04))
#define GPIOC_IDT (*(volatile unsigned int*)(0x40011000+0x08))
#define GPIOC_ODT (*(volatile unsigned int*)(0x40011000+0x0C))
#define GPIOC_SCR (*(volatile unsigned int*)(0x40011000+0x10))
#define GPIOC_CLR (*(volatile unsigned int*)(0x40011000+0x14))
#define GPIOC_WPR (*(volatile unsigned int*)(0x40011000+0x18))
#define GPIOC_HDRV (*(volatile unsigned int*)(0x40011000+0x3C))
#define GPIOD_CFGLR (*(volatile unsigned int*)(0x40011400+0x00))
#define GPIOD_CFGHR (*(volatile unsigned int*)(0x40011400+0x04))
#define GPIOD_IDT (*(volatile unsigned int*)(0x40011400+0x08))
#define GPIOD_ODT (*(volatile unsigned int*)(0x40011400+0x0C))
#define GPIOD_SCR (*(volatile unsigned int*)(0x40011400+0x10))
#define GPIOD_CLR (*(volatile unsigned int*)(0x40011400+0x14))
#define GPIOD_WPR (*(volatile unsigned int*)(0x40011400+0x18))
#define GPIOD_HDRV (*(volatile unsigned int*)(0x40011400+0x3C))
#define GPIOE_CFGLR (*(volatile unsigned int*)(0x40011800+0x00))
#define GPIOE_CFGHR (*(volatile unsigned int*)(0x40011800+0x04))
#define GPIOE_IDT (*(volatile unsigned int*)(0x40011800+0x08))
#define GPIOE_ODT (*(volatile unsigned int*)(0x40011800+0x0C))
#define GPIOE_SCR (*(volatile unsigned int*)(0x40011800+0x10))
#define GPIOE_CLR (*(volatile unsigned int*)(0x40011800+0x14))
#define GPIOE_WPR (*(volatile unsigned int*)(0x40011800+0x18))
#define GPIOE_HDRV (*(volatile unsigned int*)(0x40011800+0x3C))
/********************************************************************************/
int main()
{
/*
CRM_CTRL |=bit0; //HICKEN HICK 使能
CRM_CFG &=~(bit1+bit0); //SCLKSEL 系统时钟选择HICK
CRM_AHBEN |=bit4; //FLASHEN 闪存时钟使能
CRM_AHBEN |=bit2; //SRAMEN SRAM 时钟使能
CRM_APB2EN |=bit6; //GPIOEEN GPIOE 时钟使能
CRM_APB2EN |=bit5; //GPIODEN GPIOD 时钟使能
CRM_APB2EN |=bit4; //GPIOCEN GPIOC 时钟使能
CRM_APB2EN |=bit3; //GPIOBEN GPIOB 时钟使能
CRM_APB2EN |=bit2; //GPIOAEN GPIOA 时钟使能
CRM_MISC1 &=~bit25; //HICKDIV HICK 6 分频(8m)
CRM_MISC3 &=~bit9; //HICK_TO_SCLK HICK作为系统时钟(0/8M,1/48M)
*/
CRM_APB2EN |=bit2; //GPIOAEN GPIOA 时钟使能
GPIOA_CFGLR |=bit0+bit1;
//GPIOA_CFGHR
while(1)
{
GPIOA_ODT |=bit0;
GPIOA_ODT &=~bit0;
}
}
|