cortex M3S811 study notes-GPIO-INT

Publisher:SereneHarmonyLatest update time:2012-10-11 Source: 21ic Keywords:cortex  M3S811  GPIO-INT Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

First of all, the general IO port. No matter what microcontroller you learn, the IO port is the most important and easiest to learn. It is important because it is the interface between the microcontroller and the peripheral device, and it is also what we usually call the human-machine interface. It is easy to learn because it is easy to control. It is nothing more than enabling the port, setting the direction, and then writing or reading data (depending on the direction you set). The IO port of this super powerful 32-bit ARM core is also different. After all, it is an ARM core, and the IO registers are also richer. Let's take a look at the functions related to the IO port.

1. In order, enable the IO port first. Only when it is enabled can it be used, so of course it is the first step.
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA)

This is the function to enable port A, that is, port A can be used, and its door is open to you.
Doesn't port A have 6 pins in physical characteristics? GPIOA represents those 6 pins.
So how many other general IO ports does M3 have? Just count them and you will know. If you want to use it, you must understand it well. PA 0-5 PB 0-7 PC 0-7 PD 0-7 PE 0-2 ========== Is there a pattern? It seems a bit messy. Look at it this way. 51 is like this, P0, P1, P2, P3 //
Here are PA, PB, PC, PD. What about PE, where does it come from? Because our PA only has 6 pins, so it gives its two pins to others (PE1, 2). Like 51, both have 32 pins.
Remember this, PA has six pins and PE has two pins. The two PE pins can also be used as motors (because its second function is pwm4, pwm5).

Needless to say, the other pins are 8 for power and ground, reset, two for crystal oscillator, and LD0 for voltage regulator. This is a total of 44 pins, and the remaining four pins are AD interfaces AD0-AD3. Just now, the port was enabled, and the port became active and can be used, but the function word is too long and I can't remember it. What should I do? Just make a macro definition, make one that I know.
#define DEVICEEN SysCtlPeripheralEnable
enables the device, and that's it.

What is the second step? What do you want to do? The most common thing is, are you going to connect a button (input) or an LED (output)?
Yes, it is to set the direction, there are three directions.
void GPIOPinTypeGPIOInpu (unsigned long ulPort, unsigned char ucPins)
void GPIOPinTypeGPIOOutput (unsigned long ulPort, unsigned char ucPins)
ulPort is which port, ucPins is which pin or pins
The function name is too long, so it is better to make a macro definition that you are familiar with
#define GPIOIN GPIOPinTypeGPIOInpu
#define GPIOOUT GPIOPinTypeGPIOOutput
Now let's take an example: set the 0th pin of PA as output and the second pin as input.

GPIOOUT (GPIO_PORTA_BASE, GPIO_PIN_0)
GPIOIN (GPIO_PORTA_BASE, GPIO_PIN_2)

Of course, I still think that GPIO_PORTA_BASE, GPIO_PIN_2 are too long.
After all, they are things that we need to deal with frequently. I will make a macro definition:
#define PA GPIO_PORTA_BASE
#define PIN2 GPIO_PIN_2

Then the above statement becomes, GPIOIN (PA, PIN2);
which feels a lot clearer (Note: you must remember the macros you defined)


In the third step, the direction is also set, so all that’s left is reading and writing numbers.
void GPIOPinWrite(unsigned long ulPort, unsigned char ucPins, unsigned char ucVal);
long GPIOPinRead(unsigned long ulPort, unsigned char ucPins)

Then macro definition:
#define WRITE GPIOPinWrite
#define READ GPIOPinRead

Now you can turn on the light. If your PA0 is connected to an LED (cathode is grounded),
you only need this statement to light it up: WRITE(PA,PIN0,1);

Keywords:cortex  M3S811  GPIO-INT Reference address:cortex M3S811 study notes-GPIO-INT

Previous article:Solutions based on embedded multimedia entertainment controller
Next article:USB design based on STM32

Recommended ReadingLatest update time:2024-11-17 01:32

ARM7 vs ARM Cortex
1. ARM implementation method ARM Cortex is the latest ARM embedded core based on the ARM7v architecture. It uses Harvard architecture and separate instruction and data buses (under the von Neumann architecture, data and instructions share a bus). In essence, the Harvard architecture is more complex physically,
[Microcontroller]
Features of the ARM Cortex-M0+ core
Learning M0+         Learn M0+ from three aspects: Learn the M0+ chip manual, learn codewarrior10.4, and try to use the MQX real-time system. First learn about this M0+ core. Kernel and architecture: ARM Cortex-M0+ core, up to 48MHz and supports zero-wait execution from memory;         Single-cycle I/O access:
[Microcontroller]
Make a gravity sensing remote control with Cortex-M3 and ADXL345
 I haven't written an article for a long time because I haven't had the time. People say that if you don't prepare for the postgraduate entrance examination in your senior year, every day will be like New Year's Day, but I still don't have that kind of free time. Now almost everyone has an Android smartphone, which I
[Power Management]
Make a gravity sensing remote control with Cortex-M3 and ADXL345
ARM processor base Cortex-M4
Startup Process Processor operating mode Processor modes are divided into thread mode and processing mode; software execution is divided into privileged mode and non-privileged mode (user mode); the stack is divided into MSP Main stack and PSP Program stack. In process mode, it is always privile
[Microcontroller]
ARM processor base Cortex-M4
Research and implementation of floating-point operations in Cortex-M3 core
Introduction In some more complex operations, it is often necessary to process floating-point data with a large value range and high precision. However, there is no floating-point hardware arithmetic unit in general low-end embedded cores, so it is difficult to process data such as voice signals. This paper prop
[Microcontroller]
Research and implementation of floating-point operations in Cortex-M3 core
The concept of priority of cortex-m3
There are two priority concepts in STM32 (Cortex-M3) - preemptive priority and response priority. Some people call response priority "sub-priority" or "sub-priority". Each interrupt source needs to be assigned these two priorities. An interrupt with a high preemptive priority can interrupt an interrupt with a low pr
[Microcontroller]
cortex-a8 uboot series: Chapter 13 uboot command system
1. uboot command implementation code The implementation code of the Uboot command system is in common/cmd_xxx.c. There are several .c files related to the command system. (There are also command.c main.c)   Each command corresponds to a function Each uboot command corresponds to a function. This is an idea and method
[Microcontroller]
cortex-a8 uboot series: Chapter 13 uboot command system
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号