Today I made a running light program, and the compilation environment was KEIL for ARM.
At first, I installed ADS debugging software for ARM, which is a compilation environment specifically for debugging ARM, and then used H-JTAG software for downloading and debugging. But today, I used KEIL for ARM to compile, because I am familiar with the KEIL environment, so I used KEIL for debugging. I made the first demonstration program, the LED water light program.
Today I also learned that ARM debugging can choose RAM space for debugging or ROM debugging. Now I use the parallel port H-JTAG, and I can also use D-LINK and other debuggers.
I downloaded the data sheet and user manual of PLC2103, which can be downloaded from www.NXP.com . There are also application notes available for download, which are quite practical.
Today I learned how to use and configure the I/O port.
IODIR is used to configure the IO port input and output
IOSET sets the IO port to high
IOCLR sets the IO port to low
IOPIN read IO port data
H-JTAG installation and use
Can detect ARM7 chip (LPC2103)
How to connect with KEIL and ADS is introduced in the HELP document, so the details are not recorded here.
The following introduces the installation, software cracking, and configuration of the keil for ARM compilation environment.
Install MDK350PRC.EXE, then run KEIL_Lic.exe to crack, first run KEIL
The first running light program: You need to create a new project file named led and select the chip as follows:
Here is a brief description of how to debug in KEIL:
Click to enter the debugging interface. First, you need to configure H-JTAG for use in KEIL.
View the data sheet in HELP in the H-JTAG software
Select chip type
Fill in the crystal
Select the download format Intel Hex format and select the file path
In KEIL, you also need to configure: ROM and RAM configuration
After configuration, click Debug
The H-Flasher interface appears, click Program to debug.
LED water light source program:
/**************ARM7(LPC2103) exercise program******************************/
/****************************************************** ************/
/*****File Function : LED Display *****/
/*****Program Author : ZhengWen(ClimberWin) *****/
/*****MCU: LPC2103F external 12M crystal oscillator*****/
/*****Compile Date : 2009/12/2 *****/
/*****Edition Info : V1.0 *****/
//Compilation environment KEIL for ARM
//LED interface P0.0-P0.7
//LED running light program OK, the first ARM practice program
#include
#include
#define uint unsigned int
#define uchar unsigned char
void delayms(unsigned int count);//delay program
void led_display(void); //Flowing light display program
/*************Delay program*******************/
void delayms(unsigned int count)
{
unsigned int i,j;
for(i=0;i for(j=0;j<5000;j++); } /**********Flowing light display program*********/ void led_display(void) { uchar i; for(i=0;i<8;i++) { IO0SET=0xff; IO0CLR=(1<
delayms(100); } } //////////////Main program//////////////////// void main(void) { IO0DIR=0x000000ff; //Configure P0.0-P0.7 as output while(1) { led_display(); //Flowing light display program } } Notes for Thursday, December 3, 2009 Start learning LPC2103 UART serial port UART0 Exercise U0LCR Configuration Baud rate calculation formula: DivAddVal/MulVal is used for frequency division, and the values are as follows: This can reduce the baud rate error. When DivAddVal/MulVal=0; So the values of the high and low bits of the latch can be calculated U0DL = (PCLK/16)/baudrate; U0DLM= U0DL/256; U0DLL = U0DL%256; When you start setting the serial port parameters, you need to set DLAB of U0LCR to 1 When you finish setting the serial port parameters, you need to set the DLAB of U0LCR to 0. Test results: UART0 test source program: /**************ARM7(LPC2103) exercise program******************************/ /****************************************************** ************/ /*****File Function : UART test *****/ /*****Program Author : ZhengWen(ClimberWin) *****/ /*****MCU: LPC2103F external 11.0592M crystal oscillator*****/ /*****Compile Date : 2009/12/3 *****/ /*****Edition Info : V1.0 *****/ /****************************************************** ************/ //Compilation environment KEIL for ARM //Function description: Serial port exercise, use UART0 to send characters and strings to the serial port #include #include #define uint unsigned int #define uchar unsigned char #define PCLK 11059200 //Crystal oscillator frequency #define baudrate 9600 //Set the baud rate #define PE (U0LSR&0x40) //Define whether the serial port is busy or not, PE=1 busy; PE=0 not busy green void delayms(unsigned int count); //delay program void UART0_INT(void); //Serial port initialization void UART0_SendByte(unsigned char data void UART0_SendStr(unsigned char const *str);//Serial port sends string /*************Delay program*******************/ void delayms(unsigned int count) { unsigned int i,j; for(i=0;i for(j=0;j<5000;j++); } /***********Serial port 0 initialization**********************/ void UART0_INT(void) { unsigned short int U0DL; U0LCR = 0x83; // DLAB = 1, baud rate can be set; no parity check, 1 stop bit, 8-bit data length. U0DL = (PCLK/16)/baudrate; U0DLM= U0DL/256; //high 8 bits U0DLL = U0DL%256; //low 8 bits U0LCR = 0x03; // DLAB = 0, set the baud rate; no parity, 1 stop bit, 8 data bits. } /***********Serial port sends bytes**********************/ void UART0_SendByte(unsigned char da { U0THR = da while( PE==0 ); //Wait for data to be sent PE=1 busy; PE=0; not busy green } /***********Serial port sends string**********************/ void UART0_SendStr(unsigned char const *str) { while(1) { if( *str == '\0' ) break; UART0_SendByte(*str++); //Send data } } //////////////Main program//////////////////// int main(void) { PINSEL0 = 0x00000005; //Set I/O connection to UART0 PINSEL1 = 0x00000000; UART0_INT(); //Serial port initialization while(1) { UART0_SendStr("LPC2103 UART0 Test OK!"); //Send string to the serial port delayms(1000); } return(0);} Friday, December 4, 2009 Learn LCD12864 control, ported from AVR program The debugging was successful, but some problems occurred in the middle and the cause was not found. It turned out to be a timing problem. It was normal on AVR, but there was a problem on LPC2103. It was due to timing. IO0SET=LCD_SCLK; DELAY(100); //This delay program was not originally added, so an error occurred. It will work normally after adding it. IO0CLR=LCD_SCLK; LCD12864 transplantation is successful. 2009 12.4.16:00 LCD12864 liquid crystal display source program: /**************ARM7(LPC2103) exercise program******************************/ /****************************************************** ************/ /*****File Function: LCD12864 display *****/ /*****Program Author : ZhengWen(ClimberWin) *****/ /*****MCU: LPC2103F external 11.0592M crystal oscillator*****/ /*****Compile Date : 2009/12/4 *****/ /*****Edition Info : V1.0 *****/ /****************************************************** ************/ //Compilation environment KEIL for ARM //Function description: LCD12864 display program #include #include #define uint unsigned int #define uchar unsigned char #define LCD_CS (1<<0) //Chip select high level is valid. When using a single-chip LCD, the high level can be fixed. #define LCD_SID (1<<1) //data r/w #define LCD_SCLK (1<<2) //clock e uchar const HEX_[]={"0123456789ABCDEF"}; uchar BUFFER[6] = {0}; uchar K_NUM; void DELAY(uchar t); void LCD_SEND(uchar date); void LCD_SCOM(uchar st,uchar date); void LCD_DELAY(void); void LCD_INIT(void); void LCD_write(uchar *p); void LCD_LOCAL(uchar x,uchar y,uchar *p); void LCD_cblank(uchar x,uchar y); void LCD_count(long s,uchar x1,uchar y1,uchar x,uchar y,uchar *p); void LCD_bai(); void Delay1ms(unsigned int count); /*************Delay program*******************/ void delayms(unsigned int count) { unsigned int i,j; for(i=0;i for(j=0;j<5000;j++); } void Delay1ms(unsigned int count) { unsigned int i,j; for(i=0;i for(j=0;j<120;j++); } void DELAY(uchar t) { while(--t); } void LCD_SEND(uchar date) { uchar i; //LCD_SCLK=0; IO0CLR=LCD_SCLK; for(i=0;i<8;i++) { //LCD_SID=date&0x80; if((date&0x80)==0) {IO0CLR=LCD_SID;} else { IO0SET = LCD_SID;} //LCD_SCLK=1; //LCD_SCLK=0; IO0SET=LCD_SCLK; DELAY(100); IO0CLR=LCD_SCLK; date<<=1; } } void LCD_SCOM(uchar st,uchar date) { uchar st_temp,hdate,ldate; if(st) st_temp=0xfa; else st_temp=0xf8; hdate=date&0xf0; ldate=date&0x0f; ldate <<= 4; // LCD_CS = 1; IO0SET=LCD_CS; LCD_SEND(st_temp); LCD_SEND(hdate); LCD_SEND(ldate); //LCD_CS = 0; IO0CLR=LCD_CS; DELAY(38); } void LCD_DELAY(void) { uchar s; s=10; while(--s) DELAY(250); } void LCD_INIT(void) { LCD_SCOM(0,0x30); LCD_DELAY(); LCD_SCOM(0,0x0c); LCD_DELAY(); LCD_SCOM(0,0x01); //Clear the screen and reset the DDRAM address counter to zero LCD_DELAY(); } void LCD_write(uchar *p) { while(*p) { LCD_SCOM(1,*p); p++; } } void LCD_LOCAL(uchar x,uchar y,uchar *p) //lcd string (x,y) write! { switch (x) { case 1:LCD_SCOM(0,0x7f+y); LCD_write(p);break; case 2:LCD_SCOM(0,0x8f+y); LCD_write(p);break; case 3:LCD_SCOM(0,0x87+y); LCD_write(p);break; case 4:LCD_SCOM(0,0x97+y); LCD_write(p);break; default :LCD_SCOM(0,0x7f+y); LCD_write(p); } } void LCD_cblank(uchar x,uchar y) { switch (x) { case 1:LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);break; case 2:LCD_SCOM(0,0x8f+y); LCD_SCOM(0,0x0d);break; case 3: LCD_SCOM(0,0x87+y); LCD_SCOM(0,0x0d);break; case 4:LCD_SCOM(0,0x97+y); LCD_SCOM(0,0x0d);break; default :LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d); } } /************************************************/ main() { //main start Delay1ms(1000); IO0DIR=0x000000ff; //Configure P0.0-P0.7 as output Delay1ms(1000); LCD_INIT(); Delay1ms(1000); LCD_LOCAL(1,1,"LPC2103 exercise program"); LCD_LOCAL(2,1,"LCD12864 display program"); LCD_LOCAL(3,1,"Welcome to Huoxin Electronics"); LCD_LOCAL(4,1,"www.huo-xin.com "); while(1); }
Previous article:ARM9 learning---data communication between LINUX in virtual machine and main XP system
Next article:STM8S103 watchdog application
Recommended ReadingLatest update time:2024-11-23 16:35
- Popular Resources
- Popular amplifiers
- Practical Deep Neural Networks on Mobile Platforms: Principles, Architecture, and Optimization
- ARM Embedded System Principles and Applications (Wang Xiaofeng)
- ARM Cortex-M4+Wi-Fi MCU Application Guide (Embedded Technology and Application Series) (Guo Shujun)
- An ARM7-based automotive gateway solution
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- 12-bit ADC
- [Anxinke UWB indoor positioning module NodeMCU-BU01] No.003-Application program joint debugging
- New Bluetooth TFT color screen capacitive touch electronic bracelet 10 yuan each
- Questions about burning program
- In China's Internet of Things industry chain, which field are the companies you are familiar with in?
- Research and application of GaN materials
- MSP430 MCU Tutorial
- Texas Instruments Wireless Connectivity Solutions
- What does it mean to have a window in the solder mask layer of a PCB? Reasons for having a window in the solder mask layer of a PCB
- Altium Designer AD component package library