Lepomux Kernel Patch
| Why do I have to patch my brickOS kernel? |
|---|
|
Using Lepomux requires a stable timing on the motor port because it is used as a serial data port. Since brickOS does a lot of stuff simultaneously, it's not enough to use functions like msleep(). Task scheduling, LCD refresh and other things may occur, which will make it impossible to generate constant data rates. Furthermore, there had to be some function which enables us to use this serial data transfer inside our RCX-programs. So we decided to add another motor state (data) and to use the speed setting as a place to put the dataword we want to send. The only limitation is that we can't send zeros - because zero means 'transfer done'. The serial protocol is implemented in assembler, which means that we can just write data with motor_b_speed(), check for acknowledge on one of our sensor-inputs and be happy. Note: Only port B implements our data-out functionality. |
| How does it work? |
|
The whole brickOS timing is based on a 1ms-interrupt produced by timer A. Some of the ROM-internal functions use this interrupt too (e.g. sound routines). Task scheduling, sensor readout, display refresh and tons of other stuff is done in that interrupt. So even if you write a lowlevel driver, it's impossible to produce a static timing. To solve this problem, we decided to drive the motors seperately by another interrupt. Unfortunately, this interrupt needs to have a higher priority than the system-interrupt and timer A is already the one with the highest priority on the H8. So here comes the evil stuff: We put the system-interrupt on timer B, which has a slightly lower priority. Timer A only schedules the ROM-functions and the motor driver (speeding up this timer will result in a strange sound output and maybe even in other mean things happening - be warned). With this trick, it's possible to produce an (almost) stable 500 Hz output. |
| Where do I get the patch? |
|
Actually, patching your kernel right now won't make too many sense - there's no Lepomux available yet. But you can take a look at the code if you're interested in how our datatransfer-voodoo works. You can download it here. If there are any further questions just drop me a mail. |