Linux ARM (IMX6U) bare metal assembly LED driver experiment--driver writing

Publisher:知者如渊Latest update time:2021-11-01 Source: eefocusKeywords:Linux  ARM  LED driver Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Initialization of i.MX6ULL

①、Enable clock

Enable clock. The seven registers CCGR0-CCGR6 control the enable of all peripheral clocks of i.MX6ULL. For simplicity, set all seven registers CCGR0-CCGR6 to 0xFFFFFFFF, which is equivalent to enabling all peripheral clocks.


CCGR0:

insert image description here

CCGR1:

insert image description here

CCGR2:

insert image description here

CCGR3:

insert image description here

CCGR4:

insert image description here

CCGR5:

insert image description here

CCGR6:

insert image description here

The assembly enables all peripheral clocks:

insert image description here

②、Configure GPIO_I003 PIN multiplexing as GPIO

Set bit3-0 of IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO03 to 0101, so that GPIO_IO03 is multiplexed as GPIO

insert image description here

Assembly implementation:

insert image description here

③、Configure the electrical properties of IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO03

Set the electrical properties of register IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO03, including slew rate, speed, drive capability, open drain, pull-up and pull-down, etc.

insert image description here

insert image description here

Assembly code implementation:

insert image description here

④. Configure GPIO function and set input and output

Set GPIO1_GDIR register bit3 to 1, that is, set it to output mode

insert image description here
insert image description here

Assembly implementation:

insert image description here

⑤、Set bit3 of GPIO_DR register, 1 means output high level, 0 means output low level

insert image description here
insert image description here

Assembly implementation:

insert image description here

The entire assembly code (.s file):


.global _start @Global label


_start:

    /*Enable all peripheral clocks*/

    LDR R0 , =0x020c4068 @CCGR0 

    LDR R1, =0xffffffff @To write data to CCGR0

    STR R1, [R0] @Write the value of R1 into R0

    

    LDR R0 , =0x020c406c @CCGR1

    STR R1 ,[R0]


    LDR R0 , =0x020c4070 @CCGR1

    STR R1 ,[R0]


    LDR R0 , =0x020c4074 @CCGR1

    STR R1 ,[R0]


    LDR R0 , =0x020c4078 @CCGR1

    STR R1 ,[R0]


    LDR R0 , =0x020c407c @CCGR1

    STR R1 ,[R0]


    LDR R0 , =0x020c4080 @CCGR1

    STR R1 ,[R0]


    /*Configure GPIO_I003 PIN multiplexing as GPIO

    * IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO03 = 0101 = 5

    * The address of IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO03 register is 0x020E_0068

    */

    LDR R0 , =0x020E0068 @IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO03

    LDR R1 , =0x5 @Data to be written

    STR R1 , [R0] @Write 5 to IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO03


    /*Configure the electrical properties of IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO03

    * The address of IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO03 is 0x020E_02F4

    * bit0: 0 low rate

    * bit5-3: 110 R0/6 drive capability

    * bit7-6: 10 100MHz speed

    * bit11: 0 turns off open-circuit output

    * bit12: 1 enable pull/keeper

    * bit15-14: 00 100K pull-down

    * bit16: 0 turn off hys    

    * Write 0x10b0 to register IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO03

    */


    LDR R0 , = 0x020E02F4

    LDR R1 , = 0x10b0

    STR R1 ,[R0]


    /*Set GPIO function

     * Set GPIO1_GDIR register Set GPIO1_GPIO03 as output

     *The address of register GPIO_GDIR is 0x0209C004

     * Set GPIO1_GDIR register bit3 to 1, which means GPIO1_GPIO03 is output

     */

    LDR R0 , = 0x0209C004

    LDR R1 , = 0x8

    STR R1 ,[R0]


    /*Turn on the LED, that is, set GPIO1_GPIO03 to 0 

     *GPIO1_DR register address is 0x0209C000

    */


    LDR R0 , = 0x0209C000

    LDR R1, =0

    STR R1 ,[R0]


loop:

    b loop


Keywords:Linux  ARM  LED driver Reference address:Linux ARM (IMX6U) bare metal assembly LED driver experiment--driver writing

Previous article:Linux ARM (IMX6U) bare metal assembly LED driver experiment--compile driver
Next article:Introduction to ARM exception and interrupt processing (interrupt is a type of exception)

Recommended ReadingLatest update time:2024-11-16 10:39

[Linux driver] Module loading RTX8025 driver
System version: Ubuntu18.04-64 Compiler version: gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) uboot version: 2018.07-linux4sam_6.0 Board model: at91sama5d3x-xplained MCU model: sama5d36 RTC model: RX8025T RX8025T clock chip interpretation There are many ways to implement drivers in the Linux
[Microcontroller]
[Linux driver] Module loading RTX8025 driver
s3c2440 LCD screen driver (built-in kernel) linux-4.1.24
It comes with some driver configuration information. Just modify this part to support different LCD screens - /arch/arm/mach-s3c24xx/mach-smdk2440.c The other part is in /drivers/video/fbdev/s3c2410fb.c First turn on the debugging function so that the kernel can output this information when it starts, or use dmesg
[Microcontroller]
s3c2440 LCD screen driver (built-in kernel) linux-4.1.24
Simple configuration of linux-arm development environment
Simple configuration of the linux-arm development environment is the first step in learning ARM. Many beginners will struggle with this issue for a long time and cannot configure the development environment. I recommend you to watch Wei Dongshan's video, which is very detailed and basically explains the code to you (m
[Microcontroller]
Interrupt service routine jump of ARM embedded system
In a 32-bit ARM system, a branch instruction or a PC register load instruction is generally placed in the interrupt vector table to implement the function of the program jumping to the interrupt service routine. For example: IRQEntry B HandleIRQ ; jump range is smaller B HandleFIQ Or IRQEntry LDR PC, = HandleIRQ; th
[Microcontroller]
【ARM bare board】Nand Flash basics and timing analysis
1. Hardware knowledge 1.1 How to transmit address signals? DATA0 ~ DATA7 transmits both data and address (multiplexing) ALE (Address Lock Enable) address latch enable signal When ALE = 1, the address is transmitted When ALE = 0, data is transmitted 1.2 How to transmit commands? Command table According to the NAN
[Microcontroller]
【ARM bare board】Nand Flash basics and timing analysis
CES 2024: Macroblock’s LED driver chips lead the upgrade of automotive lighting and displays
(January 10, 2024) Macroblock Technology demonstrated its latest LED driver chip at CES 2024, suitable for automotive lighting and cockpit display applications. At CES 2024, the world's largest consumer electronics show, Macroblock is demonstrating its innovative technology at booth 3161 in the West Hall of the Las Ve
[Automotive Electronics]
CES 2024: Macroblock’s LED driver chips lead the upgrade of automotive lighting and displays
Processor Architecture (IX) ARM and other architecture reference manuals including content abstract
The ARM architecture is divided into multiple versions, and there are version compatibility issues. Includes what-do-we-mean-by-architecture ARM core architecture // XXX core architecture. For example, VFP Programming Model type of data Processor Mode register abnormal Big and small endian Unaligned ac
[Microcontroller]
164 drive 8-bit LED display CVAVR program
//164 driver digital tube display //Chip ATMEGA16L  //Clock 4MHz internal //Written in CVAVR, using the system's own delay function //PD0 PD1 simulate 164 timing #include     #include    #define hc164_data PORTD.0 #define hc164_clk PORTD.1   void led164_display (void); // Digital tube display void hc164_send_
[Microcontroller]
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号