九鼎创展论坛

标题: LED_x6818裸板编程 [打印本页]

作者: laohu360    时间: 2017-11-5 22:19
标题: LED_x6818裸板编程
/*
*LED Test
*
*
*/
#define GPIOB_ALTFN1_26 *((volatile unsigned int *)0xC001B024)
#define GPIOB_OUTENB_26 *((volatile unsigned int *)0xC001B004)
#define GPIOB_OUT_26        *((volatile unsigned int *)0xC001B000)

#define GPIOC_ALTFN0_11 *((volatile unsigned int *)0xC001C020)
#define GPIOC_OUTENB_11 *((volatile unsigned int *)0xC001C004)
#define GPIOC_OUT_11    *((volatile unsigned int *)0xC001C000)

#define GPIOC_ALTFN0_7 *((volatile unsigned int *)0xC001C020)
#define GPIOC_OUTENB_7 *((volatile unsigned int *)0xC001C004)
#define GPIOC_OUT_7    *((volatile unsigned int *)0xC001C000)

#define GPIOC_ALTFN0_12 *((volatile unsigned int *)0xC001C020)
#define GPIOC_OUTENB_12 *((volatile unsigned int *)0xC001C004)
#define GPIOC_OUT_12    *((volatile unsigned int *)0xC001C000)

void delay(unsigned int );

void led_test(void)
{
    /*选择管脚的功能1*/
        GPIOB_ALTFN1_26 &= ~(3<<20);
        GPIOC_ALTFN0_11 &= ~(3<<22);
        GPIOC_ALTFN0_7  &= ~(3<<14);
    GPIOC_ALTFN0_12 &= ~(3<<24);

        GPIOB_ALTFN1_26 |= 1<<20;
        GPIOC_ALTFN0_11 |= 1<<22;
        GPIOC_ALTFN0_7  |= 1<<14;
        GPIOC_ALTFN0_12 |= 1<<24;

    /*配置为输出模式*/
        GPIOB_OUTENB_26 |= 1<<26;
        GPIOC_OUTENB_11 |= 1<<11;
        GPIOC_OUTENB_7  |= 1<<7;
    GPIOC_OUTENB_12 |= 1<<12;
    while(1)
    {
               
                /*输出低电平 亮灯*/
        GPIOB_OUT_26 &= ~(1<<26);
        delay(0x1000000);
        /*输出高电平 灭灯*/
        GPIOB_OUT_26 |= 1<<26;
        delay(0x1000000);

                /*输出低电平 亮灯*/
        GPIOC_OUT_11 &= ~(1<<11);
        delay(0x1000000);
        /*输出高电平 灭灯*/
        GPIOC_OUT_11 |= 1<<11;
        delay(0x1000000);

                /*输出低电平 亮灯*/
        GPIOC_OUT_7 &= ~(1<<7);
        delay(0x1000000);
        /*输出高电平 灭灯*/
        GPIOC_OUT_7 |= 1<<7;
        delay(0x1000000);
               
                /*输出低电平 亮灯*/
        GPIOC_OUT_12 &= ~(1<<12);
        delay(0x1000000);
        /*输出高电平 灭灯*/
        GPIOC_OUT_12 |= 1<<12;
        delay(0x1000000);
    }
}

void delay(unsigned int n)
{
    while(n--) ;
}






LED_x6818裸板编程.rar

380.78 KB, 下载次数: 5


作者: nejicc    时间: 2018-4-14 11:38
我也在学这块板子,能不能留个联系方式方便交流
作者: laohu361    时间: 2018-10-24 09:38
nejicc 发表于 2018-4-14 11:38
我也在学这块板子,能不能留个联系方式方便交流

1983170646@qq.com




欢迎光临 九鼎创展论坛 (http://bbs.9tripod.com/) Powered by Discuz! X3.2