当前位置:网站首页>Improve lighting C program
Improve lighting C program
2022-07-05 07:52:00 【Soy sauce;】
explain : The watchdog timer will reset the whole system automatically , Used to update bug, Systematic self-protection mechanism

** explain :
commonly CON Is the control input and output
DAT Control the specific register control pin
So just find the corresponding one
Development manuals are important , To be able to search
Cycle lighting procedure
The method of zeroing and setting one can be the same as before to set the desired bit or and
But it's too long to write , This kind of shift is generally used
void delay(volatile int d)
{
while (d--);
}
int main(void)
{
volatile unsigned int *pGPFCON = (volatile unsigned int *)0x56000050;
// Join in volatile The system will handle it properly , Will not automatically optimize
volatile unsigned int *pGPFDAT = (volatile unsigned int *)0x56000054;
int val = 0; /* val: 0b000, 0b111 */
int tmp;
/* Set up GPFCON Give Way GPF4/5/6 Configured as output pin */
*pGPFCON &= ~((3<<8) | (3<<10) | (3<<12));
// Zero clearing
*pGPFCON |= ((1<<8) | (1<<10) | (1<<12));
// Configuration register
/* Cycle on */
while (1)
{
tmp = ~val;
tmp &= 7;
*pGPFDAT &= ~(7<<4);
*pGPFDAT |= (tmp<<4);
delay(100000);
val++;
if (val == 8)
val =0;
}
return 0;
}
In addition, the latter uses to define registers as macros , The effect is the same, don't write
Key led Program
#include "s3c2440_soc.h"
// Write the function definition here , You don't have to configure registers all the time
void delay(volatile int d)
{
while (d--);
}
int main(void)
{
int val1, val2;
/* Set up GPFCON Give Way GPF4/5/6 Configured as output pin */
GPFCON &= ~((3<<8) | (3<<10) | (3<<12));
GPFCON |= ((1<<8) | (1<<10) | (1<<12));
// Reset first and then set one
/* To configure 3 Key pins are input pins : * GPF0(S2),GPF2(S3),GPG3(S4) */
GPFCON &= ~((3<<0) | (3<<4)); /* gpf0,2 */
GPGCON &= ~((3<<6)); /* gpg3 */
// Directly clear all
/* Cycle on */
while (1)
{
val1 = GPFDAT;
val2 = GPGDAT;
if (val1 & (1<<0)) /* s2 --> gpf6 */
{
/* Release */
GPFDAT |= (1<<6);
}
else
{
/* Press down */
GPFDAT &= ~(1<<6);
}
if (val1 & (1<<2)) /* s3 --> gpf5 */
{
/* Release */
GPFDAT |= (1<<5);
}
else
{
/* Press down */
GPFDAT &= ~(1<<5);
}
if (val2 & (1<<3)) /* s4 --> gpf4 */
{
/* Release */
GPFDAT |= (1<<4);
}
else
{
/* Press down */
GPFDAT &= ~(1<<4);
}
}
return 0;
}
边栏推荐
- Oracle-触发器和程序包
- How to define guid in AMI code
- Altium designer 19.1.18 - change the transparency of copper laying
- QT excellent articles
- How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?
- Cadence simulation encountered "input.scs": can not open input file change path problem
- Altium designer 19.1.18 - clear information generated by measuring distance
- NSIS search folder
- Record the visual shock of the Winter Olympics and the introduction of the screen 2
- Apple animation optimization
猜你喜欢

UEFI development learning 3 - create UEFI program

Altium designer 19.1.18 - Import frame

II Simple NSIS installation package

万字详解八大排序 必读(代码+动图演示)

Altium Designer 19.1.18 - 清除测量距离产生的信息

Realization of binary relation of discrete mathematics with C language and its properties

Record the opening ceremony of Beijing Winter Olympics with display equipment

Opendrive ramp

Numpy——1.數組的創建

High end electronic chips help upgrade traditional oil particle monitoring
随机推荐
Apple terminal skills
Global and Chinese market of peeled bourdon tubes 2022-2028: Research Report on technology, participants, trends, market size and share
Let me teach you how to develop a graphic editor
Detailed explanation of C language pointer
[neo4j] common operations of neo4j cypher and py2neo
A series of problems in offline installation of automated test environment (ride)
Realization of binary relation of discrete mathematics with C language and its properties
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of resistivity meter 2022-2028: Research Report on technology, participants, trends, market size and share
Numpy——1.數組的創建
Altium Designer 19.1.18 - 隐藏某一个网络的飞线
Global and Chinese market of digital shore durometer 2022-2028: Research Report on technology, participants, trends, market size and share
Batch modify the txt file code to UTF-8 (notepad++)
Nombre - 1. Création de tableaux
Latex notes
通过sql语句统计特定字段出现次数并排序
Package ‘*****‘ has no installation candidate
Explain STM32 startup file in detail
Altium Designer 19.1.18 - 清除测量距离产生的信息
Altium designer 19.1.18 - clear information generated by measuring distance