Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
software:deep:rts:os [2011-06-09 16:20] – graf | software:deep:rts:os [Unbekanntes Datum] (aktuell) – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== Operating System ===== | ||
- | The mpc555 can be programmed either using interrupts in a foreground/ | ||
- | When choosing a RTOS you can select a simple, robust and very efficient non-preemtive tasking system (class mpc555.Task). The very popular MicroC/OSII will be also available on request. | ||
- | For any RTOS 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 pr-duce exceptions at a very high frequency. | ||
- | The basic modules are all written in Java. All the necessary hardware resources can be accessed through special built methods. | ||
- | ===== Class Constructors and the main() Method ===== | ||
- | When starting up a Java system has to call the static constructor of every class loaded and finally calls the main method. Our system does not support a main method. This has the advantage that you can have as many root level classes (or application classes) as you like. In IDE (to be done) you can see how to build several root level classes into the same project. | ||
- | An example of using a class constructor is shown in the following section. | ||
- | ===== Non-Preemptive Tasking System ===== | ||
- | The class mpc555.Task offers a very efficient non-preemtive scheduler. The basic timing resolution is 1ms. You can create and install as many tasks as you like. Care must be taken that each of those tasks terminates after a reasonably short time span. Control is than taken over by the scheduler which chooses the next available task in a round-robin fashion. \\ | ||
- | There are two types of tasks: ready tasks have a period of 0. That is they are scheduled as quickly as possible. There repetition frequency depends highly on the processor load and the task code itself. Periodic tasks have a non-zero period. They get scheduled after the system time passes the assigned period of the task.\\ | ||
- | The following code shows how to create and install a task. | ||
- | |||
- | <code java> | ||
- | public class TestTask extends Task{ | ||
- | |||
- | public void action () { | ||
- | // put task code here | ||
- | } | ||
- | |||
- | static { | ||
- | Task task1 = new TestTask(); | ||
- | task1.period = 500; // call twice per second | ||
- | Task.install(task1); | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | ===== Interrupts ===== | ||
- | The mpc555 has no hardware priorization scheme when dealing with interrupts. Also there is no interrupt vectoring. All the potential internal and external interrupt sources get vectored to the same memory location and are dealt with by a software scheduler. You have to assign a level to each of the interrupts. A low level means a high priority. To achieve highest efficiency interrupt nesting is switched off. That makes it necessary to write small interrupt routines. | ||
- | |||
- | ==== Internal Interrupts ==== | ||
- | Internal interrupts are all those who are caused by built-in peripheral modules, like TPU, ADC and communication interfaces. You can use them by extending the class Interrupt, write your own action-Method and install this object into the interrupt scheduler by calling // | ||
- | |||
- | <code java> | ||
- | public class IntTest extends Interrupt { | ||
- | |||
- | public void action() { | ||
- | // put your code here | ||
- | } | ||
- | |||
- | static { | ||
- | IntTest int = new IntTest(); | ||
- | int.enableRegAdr = registername; | ||
- | int.flagRegAdr = registername; | ||
- | Interrupt.install(int, | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | ==== 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 // | ||
- | |||
- | <code java> | ||
- | public class ExtIntTest extends Interrupt { | ||
- | |||
- | public void action() { | ||
- | // put your code here | ||
- | } | ||
- | |||
- | static { | ||
- | ExtIntTest int5 = new ExtIntTest(); | ||
- | Interrupt.install(int5, | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | 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 ==== | ||
- | 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> | ||
- | void MyExampleMethod () { | ||
- | ... | ||
- | US.PUTSPR(EID, | ||
- | ... // critical section | ||
- | US.PUTSPR(EIE, | ||
- | ... | ||
- | } | ||
- | </ | ||
- | |||
- | ==== 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. | ||
- | |||
- | <code java> | ||
- | public class DecrementerTest extends Decrementer { | ||
- | static int count; | ||
- | |||
- | public void action() { | ||
- | // put your code here | ||
- | } | ||
- | |||
- | static { | ||
- | DecrementerTest d = new DecrementerTest(); | ||
- | d.decPeriodUs = 1000000; // period is 1 s | ||
- | Decrementer.install(d); | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | Please make sure that your exception code is reasonably short and that the processor is able to finish prior to a new decrementer exception. | ||
- | |||
- | ==== Floating Point Numbers in Exceptions ==== | ||
- | In order to use the built in floating point unit of the processor the compiler has to include the floating point registers when doing a context save. To minimize the associated overhead when not using floating point numbers in exceptions the user has to call the function // | ||