Four programs need to be added to the project: S3C2440A.s; 2440lib.c; main.c; led.c.
Main program:
/*********************************************************************************************
* File name: main.c
* Author: ZXL
* Description: 1. Marquee 2. LED lights display 1-15 in binary format
* History: 2013.5.5
*********************************************************************************************/
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
void dely(U32 tt)
{
U32 i;
for(;tt>0;tt--)
for(i=0;i<10000;i++);
}
void init()
{
U32 i;
U8 key;
U32 mpll_val=0;
i = 2 ;
switch ( i ) //Set the clock frequency of 2440
{
case 0: //200
key = 12;
mpll_val = (92<<12)|(4<<4)|(1);
break;
case 1: //300
key = 13;
mpll_val = (67<<12)|(1<<4)|(1);
break;
case 2: //400
key = 14;
mpll_val = (92<<12)|(1<<4)|(1);
break;
case 3: //440!!!
key = 14;
mpll_val = (102<<12)|(1<<4)|(1);
break;
default:
key = 14;
mpll_val = (92<<12)|(1<<4)|(1);
break;
}
//MDIV=92,PDIV=1,SDIV=1 Determined by configuring MPLLCON, MPLL, that is, FCLK=400MHZ
ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
ChangeClockDivider(key, 12); //FCLK:HCLK:PCLK = 1:1/4:1/8 =400M:100M:50M
Port_Init();
Uart_Init(0,115200);
Uart_Select(0);
Uart_Printf("nLED Test Begin!n");
}
int main(int argc, char **argv)
{
heat();
led_port_init();
while(1)
{
led();
}
}
LED Program:
/*********************************************************************************************
* File name: led.c
* Author: ZXL
* Description: 1. Marquee 2. Press numbers 1-15 to light up the LED lights incrementally
* History: 2013.5.5
*********************************************************************************************/
#include "def.h"
#include "2440lib.h"
#include "2440addr.h"
#define LED1_ON ~(1<<5)
#define LED2_ON ~(1<<6)
#define LED3_ON ~(1<<7)
#define LED4_ON ~(1<<8)
#define LED1_OFF (1<<5)
#define LED2_OFF (1<<6)
#define LED3_OFF (1<<7)
#define LED4_OFF (1<<8)
void led_port_init()
{
rGPBCON &= ~((3<<10)|(3<<12)|(3<<14)|(3<<16)); //Control register clear
rGPBCON |= (1<<10)|(1<<12)|(1<<14)|(1<<16); //Control register is set to output
rGPBDAT |= (LED1_OFF)|(LED2_OFF)|(LED3_OFF)|(LED4_OFF); //All LED lights are off
}
void disp_num(int data)
{
if(data & 0x01) rGPBDAT &= (LED1_ON);
else rGPBDAT |= (LED1_OFF);
if(data & 0x02) rGPBDAT &= (LED2_ON);
else rGPBDAT |= (LED2_OFF);
if(data & 0x04) rGPBDAT &= (LED3_ON);
else rGPBDAT |= (LED3_OFF);
if(data & 0x08) rGPBDAT &= (LED4_ON);
else rGPBDAT |= (LED4_OFF);
}
void led() //LED lights display 1-15 in binary mode
{
U32 i;
for(i=0;i<16;i++)
{
disp_num(i);
daily(100);
}
}
/*
void led()
{
//Marquee program
while (1)
{
rGPBDAT &= (LED1_ON);
daily(100);
rGPBDAT |= (LED1_OFF)|(LED2_OFF)|(LED3_OFF)|(LED4_OFF);
daily(100);
rGPBDAT &= (LED2_ON);
daily(100);
rGPBDAT |= (LED1_OFF)|(LED2_OFF)|(LED3_OFF)|(LED4_OFF);
daily(100);
rGPBDAT &= (LED3_ON);
daily(100);
rGPBDAT |= (LED1_OFF)|(LED2_OFF)|(LED3_OFF)|(LED4_OFF);
daily(100);
rGPBDAT &= (LED4_ON);
daily(100);
rGPBDAT |= (LED1_OFF)|(LED2_OFF)|(LED3_OFF)|(LED4_OFF);
daily(100);
}
}
*/
Previous article:2440 bare metal program - key interrupt
Next article:S3C2440 bare metal -------I2C_S3C2440 I2C controller control timing
Recommended ReadingLatest update time:2024-11-16 20:30
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Circuit Diagram
- Ceramic chip high-end design technology, Slitung scalable structure analysis
- Solution to the problem that there is only one File option after opening CCS
- STMicroelectronics Industrial Tour 2019, you are sincerely invited to come!
- What should I pay attention to when using a programmable DC power supply?
- Come in and discuss how you do rust prevention.
- [RVB2601 Creative Application Development] First time to use, successfully run hello world! Project Notes
- [Mil MYS-8MMX] Mil MYS-8MMQ6-8E2D-180-C Application 2 - A Preliminary Study on NLP
- The microcontroller cannot be detected and the program cannot be downloaded
- What is the working principle of the crystal oscillator in the microcontroller?