arm cortex m0 lpc1114 register configuration

Publisher:星光曲折Latest update time:2016-12-10 Source: eefocusKeywords:arm  cortex  lpc1114 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The various data registers and control registers inside a 32-bit microcontroller are all 32 bits. Similarly, the data and control registers inside an 8-bit microcontroller are all 8 bits.

 

For example:

The definition of "interrupt control register" IE of AT89C51 microcontroller is shown in the figure below:

bit7bit6bit5bit4bit3bit2bit1bit0
EAreserveET2ESET1EX1ET0EX0

 

The definition of LPC1114's "AHB bus clock control register" SYSAHBCLKCTRL is shown in the figure below:

 

bit31bit30bit29bit28bit27bit26bit25bit24
reservereservereservereservereservereservereservereserve
bit23bit22bit21bit20bit19bit18bit17bit16
reservereservereservereservereserveSSP1reserveIOCON
bit15bit14bit13bit12bit11bit10bit9bit8
WDTreserveADCUARTSSP0CT32B1CT32B0CT16B1
bit7bit6bit5bit4bit3bit2bit1bit0
CT16B0GPIOI2CFLASH2FLASH1RAMROMSYS

 

The above two control registers, one is 8-bit and the other is 32-bit. The similarity between them is that each bit determines a task. For example, writing 1 to bit4 of the IE register of the AT89C51 microcontroller can turn on the serial port interrupt, and writing 0 can turn off the serial port interrupt. Writing 1 to bit6 of the AHBCLKCTRL register of the LPC1114 microcontroller means turning on the GPIO working clock, and writing 0 means turning off the GPIO working clock.

 

The IE register mentioned above can be used to enable the general interrupt with IE=0x80, or directly write EA=1 to enable the general interrupt. The way to enable with EA=1 is "bit operation". Compared with directly writing the register value, "bit operation" will change the value of the entire register, while "bit operation" will not change other values ​​in the register.

The registers of the LPC1114 microcontroller do not support "bit operations". In order to operate a certain bit without affecting the values ​​of other bits, we need to use the logical "or" and "and" operations of the C language.

For example:

 

Write 1 to bit6 of the SYSAHBCLKCTRL register:

LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);

 

Write 0 to bit6 of the SYSAHBCLKCTRL register:

LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<6);

 

In the header file lpc11xx.h, each register is defined by the structure of each module, so when we want to write a value to a register, we need to use the symbol "->" to assign a value to a member variable of the structure. In the above formula, the SYSAHBCLKCTTL register is located in the structure LPC_SYSCON, so when assigning a value to the register, we need to write it like this.

1<<6 means 1 is shifted to the left by 6, that is:

The 32-bit number 1 is represented in binary as 000000000000000000000000000000001

The 32-bit number 1 shifted left 6 times becomes 000000000000000000000000001000000

The left-shifted data is "OR"ed with the value in SYSAHBCLKCTRL. The logic of "OR" is 0, "OR" any number is any number, and 1, "OR" any number is 1, so the result is only bit6 set to 1.

 

Similarly, we can analyze the statement that writes 0 to bit6. These are all basic knowledge of C language. Please believe that experts do not have special skills, but have mastered a solid foundation.

 

Special note: The two statements for writing registers above may seem complicated at first glance, but they are actually very simple! When we want to write a value to a certain bit of a register in the future, for example, to write 1 to bit n of the BB register of the AA module, we can apply the above formula, that is:

AA->BB |=(1<

Similarly, to write 0 to bit n, that is:

AA->BB&=~(1<

Dear! Congratulations, you have learned most of it.


Keywords:arm  cortex  lpc1114 Reference address:arm cortex m0 lpc1114 register configuration

Previous article:18b20 measuring temperature - lpc1114
Next article:Pin overview of ARM Cortex M0 LPC1114

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号