OK6410 Assembly Program Exercise

Publisher:binggegeLatest update time:2017-02-26 Source: eefocusKeywords:OK6410 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Try to use the 6410 assembly, and find that it is similar to the 51 of that year. Learn step by step

 

  1. ;****************************************************** *************************************************** **********  

  2. ;* File name: ok6410.s  

  3. ;* Function: S3C6410 assembly  

  4. ;* Author: cp1300@139.com  

  5. ;* Created: January 4, 2013 21:27  

  6. ;* Last modified: January 4, 2013  

  7. ;* Details:        

  8. ;****************************************************** *************************************************** **********/  

  9.   

  10. TINT_CSTAT EQU 0x7F006044 ;Timer interrupt control and status register  

  11. VIC0ADDRESS EQU 0x71200F00 ; Current vector address register 0, write any data to clear interrupt  

  12. VIC1ADDRESS EQU 0x71300F00 ; Current vector address register 1, write any data to clear interrupt  

  13.   

  14. ;Call external function  

  15.     IMPORT LED1_flash ;LED1 flashing program  

  16.       

  17. ; External call function  

  18.     EXPORT Time_Isr ; Clock interrupt service routine  

  19.       

  20.       

  21.       

  22.     PRESERVE8;  

  23.     AREA S3C6410_CPU, CODE, READONLY       

  24.   

  25. ;Timer 1 interrupt service routine, note: after entering the interrupt, 6410 automatically switches to IRQ mode and turns off the IRQ interrupt. When exiting, you need to turn it on yourself or restore the CPSR     

  26. Time_Isr  

  27.     STMFD SP!, {R0,R1,LR} ;R0,R1,LR pushed onto the stack  

  28.       

  29.     LDR R0, =TINT_CSTAT           

  30.     LDR R1, [R0] ; Read register TINT_CSTAT  

  31.     ORR R1, R1, #0x01<<6 ; Write BIT6 to clear timer 1 interrupt  

  32.     STR R1, [R0] ; write back register  

  33.       

  34.     BL LED1_flash ;Call LED flashing program  

  35.       

  36.     LDR R0, =VIC0ADDRESS ; Write VIC's current interrupt address register to clear the interrupt  

  37.     LDR R1, =0xffffffff  

  38.     STR R1, [R0]  

  39.     LDR R0, =VIC1ADDRESS  

  40.     STR R1, [R0]      

  41.       

  42.     LDMFD SP!, {R0,R1,LR} ;R0,R1,LR pop  

  43.       

  44.     ;When using SUB before, it was found that the program did not recover from SPSR after exiting from the interrupt, that is, the interrupt mask was not removed. After adding -S, this instruction will affect the flag bit in CPSR, which means that SPSR_IRQ is restored to CRSP  

  45.     SUBS PC, LR, #4; To exit from the interrupt program, LR needs to be decremented by 4 and put into PC, but the subroutine call does not need -4, which should be caused by the pipeline instruction prefetch  

  46.       

  47.   

  48.   

  49.   

  50.     END  

  51.       

  52.       

  53.       


  1. /****************************************************** *************************************************** ********** 

  2. ;* File name: ok6410.h 

  3. ;* Function: S3C6410 assembly function definition 

  4. ;* Author: cp1300@139.com 

  5. ;* Created: January 4, 2013 21:27 

  6. ;* Last modified: January 4, 2013 

  7. ;* Details:       

  8. ;****************************************************** *************************************************** **********/  

  9.   

  10. #ifndef S3C6410_H_  

  11. #define S3C6410_H_  

  12.   

  13.   

  14. void Time_Isr(void); //Timer 1 interrupt service routine  

  15.   

  16. #endif /*S3C6410_H_*/  


 


  1. #include "system.h"  

  2. #include "uart.h"  

  3. #include "tft_lcd.h"  

  4. #include "other.h"  

  5. #include "delay.h"  

  6. #include "timer.h"  

  7. #include "s3c6410.h"  

  8.   

  9. void LED1_flash(void);  

  10.   

  11. /****************************************************** *************************************************** ************************ 

  12. *Function: void Timer_Init(u32 RTime,FunctionalState EnInt,void (*TimerIsr)(void)) 

  13. *Function: Timer 1 initialization function 

  14. *Parameters: None 

  15. *Return: None 

  16. *Depends on: underlying macro definitions 

  17. *Author : cp1300@139.com 

  18. *Time : 20120520 

  19. *Last modified: 20120520 

  20. * Note: Timer 0 and Timer 1 share the same prescaler 

  21. *************************************************** *************************************************** *********************/  

  22. void Timer_Init(u32 RTime,FunctionalState EnInt,void (*TimerIsr)(void))  

  23. {  

  24.     rTCFG0 |= 65; //Timer 0 pre-divided by 65+1, PCLK=66 provides the clock, 66 division generates 1MHz timer clock,  

  25.     rTCON &= (~0xff00); //Clear settings  

  26.     rTCON |= BIT11; //Timer 1 automatic update enable  

  27.     rTCNTB1 = RTime; //Reload value  

  28.     rTINT_CSTAT |= BIT6; //Clear interrupt flag  

  29.     rTINT_CSTAT |= (EnInt == ENABLE) ? BIT1 : 0; // Enable timer 0 interrupt  

  30.     Set_IsrAddr(INT_TIMER1,(u32)TimerIsr); //Set interrupt vector entry  

  31.     Set_IntEnable(INT_TIMER1,EnInt); //Enable timer 1 global interrupt  

  32.     //The following operation starts timer 0  

  33.     rTCON |= BIT9; //manual update  

  34.     rTCON &= ~BIT9; //End manual update  

  35.     rTCON |= BIT8; //Start timer 0      

  36. }  

  37.   

  38.   

  39.   

  40. //Main function  

  41. int main(void)  

  42. {         

  43. //u16 data;  

  44.       

  45.     UART0_Init(DISABLE,115200); //Initialize the serial port, disable interrupt reception, baud rate 115200  

  46.     LCD_Init(); //Initialize LCD  

  47.     LED_Init(); //Initialize LED  

  48.     Timer_Init(400000-1,ENABLE,Time_Isr); //Initialize timer 1, period 400ms  

  49.       

  50.     while(1);     

  51. }  

  52.   

  53.   

  54.   

  55.   

  56. //LED1 flashing program, flashing in timer 1 interrupt service program, period 400MS  

  57. void LED1_flash(void)  

  58. {  

  59.     LED1_FLASH();  

  60. }  


 


Keywords:OK6410 Reference address:OK6410 Assembly Program Exercise

Previous article:S3C6410 Bare Metal DMA
Next article:The problem of irrelevant code affecting decoding of S3C6410 hardware JPEG decoding has finally been solved

Recommended ReadingLatest update time:2024-11-23 18:50

ok6410 memory initialization
•DRAM: Its basic components are small capacitors that can hold charge on two plates, but need to be recharged (refreshed) regularly, otherwise the data will be lost. Disadvantages: Slow access speed due to the need to refresh the storage medium regularly. •SRAM: It is a memory with static access function, which
[Microcontroller]
ok6410 memory initialization
OK6410 bare metal learning assembly call C function to pass parameters
start.S assembly source code: .globl _start _start: // Hardware related settings      // Peri port setup      ldr r0, =0x70000000     orr r0, r0, #0x13     mcr p15,0,r0,c15,c2,4       @ 256M(0x70000000-0x7fffffff)      // Turn off the watchdog      // Write 0 to WTCON (0x7E004000)         ldr r0, =0x7E004000     mov r
[Microcontroller]
Latest Microcontroller Articles
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号