tailieunhanh - FILE ARM PROGRAMMING
“It seems that perfection is attained not when there is nothing more to add, but when there is nothing more to remove.” (Antoine de Saint-Exupery) Write your ARM programs in an easy, clear native manner. Reduce your development time to a minimum. ARM SoC is considered as a simple microcontroller but with 32-bit, MIPS, Megabytes of RAM and Gigabytes of external storage memory! | ARM PROGRAMMING Bùi Quốc Bảo When use assembly Functions that cannot be implemented in C such as special register accesses and exclusive accesses Timing-critical routines Tight memory requirements causing part of the program to be written in assembly to get the smallest memory size BÙI QUỐC BẢO 1 Example of assembly program constant for SP starting value STACK_TOP EQU 0x20002000 AREA RESET CODE THUMB DCD STACK_TOP Stack top DCD Start Reset vector AREA Vect CODE ENTRY Indicate program execution start here Start Start of main program MOV r0 10 Starting loop counter value MOV r1 0 starting result Calculated 10 9 8 . 1 R1 R1 R0 loop ADD r1 r0 SUBS r0 1 BNE loop deadloop B deadloop END Decrement R0 update ag S suf x If result not zero jump to loop Result is now in R1 Infinite loop C Programming . 1 c Data Type char short int long long long Implementation unsigned 8-bit byte signed 16-bit halfword signed 32-bit word signed 32-bit word signed 64-bit double word BÙI QUOC BẢO 2 C programming include inc int main void volatile unsigned long ulLoop SYSCTL_RCGC2_R SYSCTL_RCGC2_GPIOF ulLoop SYSCTL_RCGC2_R GPIO_PORTF_DIR_R 0x08 GPIO_PORTF_DEN_R 0x08 while 1 __ _ GPIO_PORTF_DATA_R 0x08 for ulLoop 0 ulLoop 200000 ulLoop GPiO_PoRtF_DATA_R 0x08 for ulLoop 0 ulLoop 200000 ulLoop . Startup code area reset code readonly THUMB EXPORT Vectors __Vectors DCD DCD DCD DCD DCD DCD DCD DCD DCD DCD DCD DCD DCD Top of Stack Reset Handler NMI Handler Hard Fault Handler The MPU fault handler The bus fault handler The usage fault handler StackMem Stack Reset_Handler NmiSR FaultlSR IntDefaultHandler IntDefaultHandler IntDefaultHandler 0 Reserved 0 Reserved 0 Reserved 0 Reserved IntDefaultHandler SVCall handler IntDefaultHandler Debug monitor handler BÙI QUỐC BẢO
đang nạp các trang xem trước