📄 led.c
字号:
/*******************************************************
* File Name: led.c
* Description: timing interrupt
* Author:
* Date:
*******************************************************/
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
/*define port configuration register and port data register address*/
#define PCONB (*(volatile unsigned *)0x01D20008)
#define PDATB (*(volatile unsigned *)0x01D2000C)
int i=0;
/*you may modify the value of PDATB and change the led output.PB9
and PB10 are corresponding pins to led1 OUTPUT and led2 OUTPUT.
Howover,each of port B pins is controled by register PDATB.SO you
may modify the corresponding bit of PDATB to control the led OUTPUT.*/
static void sig_alarm(int signumber)
{
if(i==0)
{
PDATB=0XF6FF;
i=1;
}
else
{
PDATB=0XF9FF;
i=0;
}
alarm(2);
}
int main(void)
{
PCONB&=0XFFCF;
if(signal(SIGALRM,sig_alarm)==SIG_ERR)
{
printf("some error occurs\n");
return 1;
}
alarm(2);
while(1);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -