当前位置:网站首页>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;
}
边栏推荐
- TCP and UDP
- Query the table name used by kettle in Oracle
- Ads usage skills
- The research found that the cross-border e-commerce customer service system has these five functions!
- STM32 learning method
- 1089 insert or merge, including test point 5
- Numpy——1.数组的创建
- How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?
- IEEE access personal contribution experience record
- 如何进行导电滑环选型
猜你喜欢

II Simple NSIS installation package

Ads learning record (lna_atf54143)

Ten thousand words detailed eight sorting must read (code + dynamic diagram demonstration)

MySQL - storage engine

Altium Designer 19.1.18 - 更改铺铜的透明度

The research found that the cross-border e-commerce customer service system has these five functions!

UEFI development learning 2 - running ovmf in QEMU

研究發現,跨境電商客服系統都有這五點功能!

Cadence simulation encountered "input.scs": can not open input file change path problem

About the problem that MySQL connector net cannot be cleared in MySQL
随机推荐
研究发现,跨境电商客服系统都有这五点功能!
Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
Opendrive record
Some errors in configuring the environment
Altium Designer 19.1.18 - 更改铺铜的透明度
Function and usage of function pointer
Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
MySql——存储引擎
LED display equipment records of the opening ceremony of the Beijing Winter Olympics
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
Embedded AI intelligent technology liquid particle counter
A series of problems in offline installation of automated test environment (ride)
String judgment
Good websites need to be read carefully
Oracle triggers and packages
[MySQL] database knowledge record
Altium designer 19.1.18 - change the transparency of copper laying
Altium designer 19.1.18 - clear information generated by measuring distance
Charles- unable to grab bags and surf the Internet
Global and Chinese market of plastic recycling machines 2022-2028: Research Report on technology, participants, trends, market size and share