Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12453 Discussions

Wrong Timeout Value with ARM A9 private timer.

Altera_Forum
Honored Contributor II
965 Views

Hello, 

I am starting a bare-metal development on DE0-Nano-SoC_Computer. 

I use the development tool: DS5 AE. 

I begin by a timer program found in the document “DE0-Nano-SoC Computer System with ARM Cortex-A9”: 

 

 

 

 

equ bit_24_pattern, 0x01000000 

 

 

 

 

 

/* this program provides a simple example of code for the arm a9. it: 

 

 

 

 

 

* 1. starts the arm a9 private timer 

 

 

 

 

 

* 2. loops forever, toggling the hps green light ledg when the timer expires 

 

 

 

 

 

*/ 

 

 

 

 

 

 

.text 

 

 

 

 

 

 

.global _start 

 

 

 

 

 

_start: 

 

 

 

 

 

 

ldr r0, =0xff709000 // gpio1 base address 

 

 

 

 

 

ldr r1, =0xfffec600 // mpcore private timer base address 

 

 

 

 

 

ldr r2, =bit_24_pattern // value to turn on the hps green light ledg 

 

 

 

 

 

str r2, [r0,# 0x4] // write to the data direction register to set 

 

 

 

 

 

// bit 24 (ledg) of gpio1 to be an output 

 

 

 

 

 

ldr r3, =200000000 // timeout = 1/(200 mhz) x 200×10∧6 = 1 sec 

 

 

 

 

 

str r3, [r1] // write to timer load register 

 

 

 

 

 

mov r3,# 0b011 // set bits: mode = 1 (auto), enable = 1 

 

 

 

 

 

str r3, [r1,# 0x8] // write to timer control register 

 

 

 

 

 

loop: 

 

 

 

 

 

 

str r2, [r0] // turn on/off ledg 

 

 

 

 

 

wait: ldr r3, [r1,# 0xc] // read timer status 

 

 

 

 

 

cmp r3,# 0 

 

 

 

 

 

beq wait // wait for timer to expire 

 

 

 

 

 

str r3, [r1,# 0xc] // reset timer flag bit 

 

 

 

 

 

eor r2, r2,# bit_24_pattern // toggle ledg value 

 

 

 

 

 

b loop 

 

 

 

 

 

 

.end 

 

 

 

 

 

The timeout is not 1 sec but about 40 sec. the good value is 5 000 000 instead of 200 000 000. 

Is it necessary to initialize the system clocks before launching the program? 

Thanks for your help. 

Jerome
0 Kudos
0 Replies
Reply