Nov 072010
 
Aki-H8 - What Works

This weekend was surprisingly successful. Here the list of things working:

  1. LCD output. I finally got the timing right: 37μs after E went low you can send another command. Clear and Home command take 1.52ms
  2. Output on Port A and B (with the exception of PB.4 which is used for /CAS for the 16MBit DRAM
  3. SPI using a HC595 (8-bit serial-in, serial or parallel-out shift register with output latches)
  4. I2C using PB.0/PB.2 for PCF8574A (8 bit quasi-bidirectional I2C port expander)
  5. I2C using P6.0/P6.1 for PCF8574A (addr 0x70) as well as 24LC256 (addr 0xA0)
  6. I2C scanning
  7. 24LC256 EEPROM reading/writing
  8. PWM using 16-bit timer ITU1 for dimming a LED
  9. Scheduling regular tasks (a la TimedAction from Arduino), which allows to run a function in regular intervals (e.g. once per second, or every 50ms, down to 1ms resolution). Not as nice as full multitasking, but it makes unrelated tasks so much easier to run.

Regarding this ‘task scheduler’, here how to use it:

initTasks();
createTasks(0, 50, knight_rider);
createTasks(2, 700, led2_blink);
createTasks(3, 5, check_key);
createTasks(4, 1000, display_something);
wait(500);
createTasks(1, 1000, eeprom);

while(!global_exit) {
  checkTasks();
}

What is does is call knight_rider() every 50ms, call led2_blink() every 700ms etc.

As an example of one of those functions:

void led2_blink(void)
{
  static int led2=1;

  LCD.BIT.LED2=led2;
  led2=!led2;
}

Next step planned: FreeRTOS port. 2 reasons:

  1. There already is a H8S port (H8S is the successor of H8/300H)
  2. There’s a TCP/IP stack for FreeRTOS available (actually several, one of them uIP and lwIP), and some of those support RTL8019AS too

Choices I dropped:

  1. eCOS. RedBoot is great and it works as a great bootloader, but it needs an old GCC tool chain and it has odd boundary requirements. The gcc toolchain I use currently just works too well to drop it.
  2. NuttX. I like it, but no RTL8019AS support and I just don’t understand how to port it to the H8/300H.
  3. MES is originally the OS running on the AKI-H8 board(s), but it depends on an old gcc tool chain and is no longer developed. MES2 only runs on more recent CPUs (SuperH and ARM). It would also not allow me to keep on using RedBoot.