maxt
Posts: 2
Joined: Fri Jan 18, 2013 1:24 am

System Clock and Interrupt help?

Fri Jan 18, 2013 1:30 am

Hey everyone, I'm new to ARM assembly programming, and I need some help. I have written a few applications for my pi in C and Assembly, and I want to now write a main scheduler to run these applications.

Every application would be given an equal amount of time to run. I was wondering if there is a timer feature on the ARM that would automatically create an interrupt when it reached 0 and stop what its currently doing and execute something else. Obviously, whatever program is running would have complete control during its time, so I can't have a main program constantly checking in on the timer.

If this is impossible, do you have any other ideas with how I can accomplish this task?

User avatar
DavidS
Posts: 4203
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: System Clock and Interrupt help?

Fri Jan 18, 2013 3:00 am

Have a look at page 196 Chapter 14 "Timer (ARM side)" in the "BCM2835 ARM" Peripherials manual, for information on the timer. For more on handling inturupts look in the "ARM Architechure Reference Manual" section A2.6.

After that if you have questions about handling exceptions/inturupts, or the timer I will be happy to help answer them to the best of my ability. And I am sure there are many others here that will help as much as they can.

Though with out knowing how much of this you know I am not sure what to say that is not in the above two documents.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

dwelch67
Posts: 954
Joined: Sat May 26, 2012 5:32 pm

Re: System Clock and Interrupt help?

Fri Jan 18, 2013 4:26 am

http://github.com/dwelch67/raspberrypi example blinker05 demonstrates a timer based interrupt with my usual long winded ramblings to go with it.

My examples are meant to be loaded at 0x8000, which when written was the default if you had no config.txt file. I have not tried the raspi firmware files in a while, I assume the default is the same. I let the linker do some work to generate the addresses to handlers, then copy that from 0x8000 to 0x0000 so that it is in the right place when the interrupt comes along (add some code knowledge, ldr pc a position independent thing so it can move). There are many other ways to prepare the exception table so that it works (well in this case only the interrupt handler or handlers (IRQ/FIQ) need to be setup as the bare minimum)

Notice I have the irq stack at 0x8000 and fiq at 0x4000, depending on where you want to load your app you may need to move those.

David

maxt
Posts: 2
Joined: Fri Jan 18, 2013 1:24 am

Re: System Clock and Interrupt help?

Fri Jan 18, 2013 2:47 pm

Thank you all for your help, that is all the information I needed. You guys are definitely a great community, and I am excited to have a pi and be a part of it!

dwelch67
Posts: 954
Joined: Sat May 26, 2012 5:32 pm

Re: System Clock and Interrupt help?

Fri Jan 18, 2013 4:05 pm

Thanks...Please pay it forward...

Return to “Bare metal, Assembly language”