This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
runtime_library:os:start [2016/02/25 13:33] – external edit 127.0.0.1 | runtime_library:os:start [2020/12/21 20:05] – ursgraf | ||
---|---|---|---|
Line 2: | Line 2: | ||
You can program the processor either using interrupts in a foreground/ | You can program the processor either using interrupts in a foreground/ | ||
When choosing an operating system you can select a simple, robust and very efficient non-preemtive tasking system (class '' | When choosing an operating system you can select a simple, robust and very efficient non-preemtive tasking system (class '' | ||
- | For any operating system the minimum task period is limited to the order of milliseconds. For fast control applications you can use the decrementer as a fast running timer and produce exceptions at a very high frequency. | + | The minimum task period is limited to one millisecond. For fast control applications you can use the decrementer |
The basic modules are all written in Java. All the necessary hardware resources can be accessed through special built-in methods. | The basic modules are all written in Java. All the necessary hardware resources can be accessed through special built-in methods. | ||
Line 14: | Line 14: | ||
<code java> | <code java> | ||
- | public class TestTask extends Task{ | + | public class TestTask extends Task { |
- | public void action () { | + | |
- | // put task code here | + | // put task code here |
- | } | + | } |
- | static { | + | |
- | Task task1 = new TestTask(); | + | Task task1 = new TestTask(); |
- | task1.period = 500; // call twice per second | + | task1.period = 500; // call twice per second |
- | Task.install(task1); | + | Task.install(task1); |
- | } | + | } |
} | } | ||
</ | </ | ||
===== Interrupts ===== | ===== Interrupts ===== | ||
- | A processor might have some sort of a hardware priorization scheme when dealing with interrupts. Some of the potential internal and external interrupt sources use vectoring or get vectored to the same memory location and are dealt with by a software scheduler. You have to assign a priority level to each of the interrupts. A low level means a high priority. In order to achieve highest efficiency, interrupt nesting is switched off. That makes it necessary to write small interrupt service routines. | + | A processor might have some sort of a hardware priorization scheme when dealing with interrupts. Some of the potential internal and external interrupt sources use vectoring or get vectored to the same memory location and are dealt with by a software scheduler. You have to assign a priority level to each of the interrupts. A low level means a high priority. In order to achieve highest efficiency, interrupt nesting is switched off. That makes it necessary to write small interrupt service routines. Further, never allocate objects within an interrupt routine or in a method called by an interrupt routine, because the heap allocation methods are not thread safe for efficiency reasons. |
- | ==== Internal | + | ==== Interrupts |
+ | === Zynq7000 Interrupts === | ||
+ | A Zynq7000 processor has private peripheral and shared peripheral interrupts and assigns each peripheral a interrupt number, see the [[https:// | ||
+ | |||
+ | <code java> | ||
+ | public class IntTest extends IrqInterrupt{ | ||
+ | |||
+ | public void action() { | ||
+ | // put your code here | ||
+ | US.PUT4(IsrReg, | ||
+ | } | ||
+ | |||
+ | static { | ||
+ | IntTest int = new IntTest(); | ||
+ | IrqInterrupt.install(int, | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Interrupts in the PowerPC Architecture ==== | ||
+ | === Internal Interrupts | ||
Internal interrupts are all those who are caused by built-in peripheral modules, like time processor units, ADC and communication interfaces. You can use them by extending the class // | Internal interrupts are all those who are caused by built-in peripheral modules, like time processor units, ADC and communication interfaces. You can use them by extending the class // | ||
Line 37: | Line 57: | ||
public class IntTest extends Interrupt { | public class IntTest extends Interrupt { | ||
- | public void action() { | + | |
- | // put your code here | + | // put your code here |
- | } | + | } |
- | static { | + | |
- | IntTest int = new IntTest(); | + | IntTest int = new IntTest(); |
- | int.enableRegAdr = registername; | + | int.enableRegAdr = registername; |
- | int.flagRegAdr = registername; | + | int.flagRegAdr = registername; |
- | Interrupt.install(int, | + | Interrupt.install(int, |
- | } | + | } |
} | } | ||
</ | </ | ||
- | ==== External Interrupts | + | === External Interrupts |
The mpc555 offers 8 external interrupt inputs. They are named IRQ0 to IRQ7. In order to use them you have to extend the class Interrupt, overwrite its action method and call the method // | The mpc555 offers 8 external interrupt inputs. They are named IRQ0 to IRQ7. In order to use them you have to extend the class Interrupt, overwrite its action method and call the method // | ||
Line 56: | Line 76: | ||
public class ExtIntTest extends Interrupt { | public class ExtIntTest extends Interrupt { | ||
- | public void action() { | + | |
- | // put your code here | + | // put your code here |
- | } | + | } |
- | static { | + | |
- | ExtIntTest int5 = new ExtIntTest(); | + | ExtIntTest int5 = new ExtIntTest(); |
- | Interrupt.install(int5, | + | Interrupt.install(int5, |
- | } | + | } |
} | } | ||
</ | </ | ||
Line 69: | Line 89: | ||
The voltage level on the external interrupt pins 5, 6 and 7 also select the operating when starting the device up. Do not override these levels during start-up! | The voltage level on the external interrupt pins 5, 6 and 7 also select the operating when starting the device up. Do not override these levels during start-up! | ||
- | ==== Switch off Interrupts Globally | + | === Switch off Interrupts Globally === |
All the external and internal interrupts can be switched off and on again, e.g. for accessing shared resources. Keep the switch-off time as low as possible. This should always be done in the following manner. | All the external and internal interrupts can be switched off and on again, e.g. for accessing shared resources. Keep the switch-off time as low as possible. This should always be done in the following manner. | ||
<code java> | <code java> | ||
void MyExampleMethod () { | void MyExampleMethod () { | ||
- | ... | + | |
- | US.PUTSPR(EID, | + | US.PUTSPR(EID, |
- | ... // critical section | + | ... // critical section |
- | US.PUTSPR(EIE, | + | US.PUTSPR(EIE, |
- | ... | + | ... |
} | } | ||
</ | </ | ||
- | ==== Decrementer Exceptions | + | === Decrementer Exceptions === |
The decrementer is a timer with a resolution of 1μs. Therefore you can use it for very fast control applications. Simply extend the class decrementer and overwrite the action method with your specific code. Make sure to set the period in μs to some meaningful value. You then have to call the //install// method. | The decrementer is a timer with a resolution of 1μs. Therefore you can use it for very fast control applications. Simply extend the class decrementer and overwrite the action method with your specific code. Make sure to set the period in μs to some meaningful value. You then have to call the //install// method. | ||
<code java> | <code java> | ||
public class DecrementerTest extends Decrementer { | public class DecrementerTest extends Decrementer { | ||
- | static int count; | + | |
- | public void action() { | + | |
- | // put your code here | + | // put your code here |
- | } | + | } |
- | static { | + | |
- | DecrementerTest d = new DecrementerTest(); | + | DecrementerTest d = new DecrementerTest(); |
- | d.decPeriodUs = 1000000; // period is 1 s | + | d.decPeriodUs = 1000000; // period is 1 s |
- | Decrementer.install(d); | + | Decrementer.install(d); |
- | } | + | } |
} | } | ||
</ | </ | ||
Line 107: | Line 127: | ||
=====System Sanity Checks ===== | =====System Sanity Checks ===== | ||
- | | + | |
- | | + | |