- /*
- * File: LEDBLINK.c
- * Purpose: Main process
- *
- */
- #include "common.h"
- #ifdef CMSIS
- #include "start.h"
- #endif
- /********************************************************************/
- void LED_init(void);
- void delay(unsigned long counnt);
- int main (void)
- {
- SystemCoreClockUpdate ();
- LED_init();
- // char ch;
-
- #ifdef CMSIS // If we are conforming to CMSIS, we need to call start here
- start();
- #endif
-
- // printf("\n\r\n\r*** Running the LEDBLINK project ***\n\r");
- while(1)
- {
- // ch = in_char();
- // out_char(ch);
- delay(60000);
- GPIOB_PTOR =1U<< 18;
- delay(60000);
- GPIOB_PTOR =1U<< 19;
- delay(60000);
- GPIOD_PTOR =1U<< 1;
- delay(60000);
- }
- }
- /********************************************************************/
- void LED_init(){
-
- SIM_SCGC5 |= 0x00001582u; //´ò¿ª PortB PortD Ä£¿éµÄʱÖÓ
-
- PORTB_PCR18|= 0x00000100u;
- PORTB_PCR19|= 0x00000100u; //ÉèÖà PTB18 19 ¸´ÓÃΪ GPIO ģʽ
- PORTD_PCR1|= 0x00000100u; //ÉèÖà PTD1 ¸´ÓÃΪ GPIO ģʽ
-
- GPIOB_PSOR |= 1U<< 18; //³õʼ»¯Êä³ö״̬Ϊ1
- GPIOB_PSOR |= 1U<< 19;
- GPIOD_PSOR |= 1U<< 1;
-
- GPIOB_PDDR |= 1U<<18; //ÉèÖÃΪÊä³ö
- GPIOB_PDDR |= 1U<<19;
- GPIOD_PDDR |= 1U<< 1;
-
- GPIOB_PCOR = 1U<< 18; //´ò¿ª
- GPIOB_PCOR = 1U<< 19;
- GPIOB_PCOR = 1U<< 1;
-
- }
- void delay(unsigned long counnt){
- volatile int i;
- for(i=0; i < counnt; i++){
-
- }
- }
- /***************/
使用这个工具很容易建立空的工程,下面就是添加自己的代码了,没有库,相信寄存器操作难不到你吧。
在调试的过程中,不知道如何粗略确定 延迟函数的时间是多少。
|