cybiko:registeraccess

You can access the memory locations but you obviously couldn't expect to have an interrupt point to byte code. I've used the green LED in many of my projects in bytecode. exp:

 #define LED (*(char *)0xFFFF61) // Green LED register
 
 void more(void)
 {
  LED |= 8; // Turn Green LED ON
  _getch();
  LED &= 247; // Turn Green LED OFF 
              // or more succinctly
  LED &= ~8;
 }

For a map of the ports see H8PortMap

porttester.zip is demonstration program that runs against the Cybiko CONSOLE that makes various called against the H8 PORTS.

A source of the portTester program is shown below:

 #include <cybiko.h>
 
 struct module_t main_module;
 
 #define PORT2  0xFFFF61
 #define GREENLED 0x08   // 3 - TMCI0
 #define REDLED   0x04   // 2 - TMRI0
 
 #define PORT4 0xFFFF53
 #define PORT4_MASK 0x0f    // Only bottom 4 bits are valid
 #define AN3     0x04   // 3 - AN3 - NC 
 #define BATLEV1 0x02   // 2 - AN2 - battery level
 #define BATLEV2 0x01   // 1 - AN1 - battery level
 #define RFLEV   0x00   // 0 - AN0 - RF Signal Strength
 
 #define  HD66421_SET (*(char *)0x600000)
 #define  HD66421_USE (*(char *)0x600001)
 
 #define  CR1_BASE 0x59  // Default state for Control register 1
 #define  CR1_DISP 0x40
 #define  CR1_STBY 0x10
 #define  CR1_RVRS 0x04
 
 void togglePort(long port, short mask, char *text) {
        TRACE("Enable %s",text);
        (*(char *)port) |= mask;
        sleep(2000);
 
        TRACE("Disable %s",text);
        (*(char *)port) &= ~mask;
        sleep(2000);
 }
 /**
 * Main entry point
 */
 long main(int argc, char* argv[], bool start)
 {
        char port4;
        char batlev;
        init_module( &main_module );
 
        TRACE("Direct port access demonstration");
        sleep(1000);
 
        // NOTE: If you have the cybiko running on MAINS
        //       then you will not see the red LED toggle.
        togglePort(PORT2, GREENLED, "Green LED");
        togglePort(PORT2, REDLED, "Red LED");
        togglePort(PORT2, REDLED|GREENLED, "Red&Green LED");
 
        port4 = (*(char *)PORT4) & PORT4_MASK;
        TRACE("RF Strength %d", port4 & RFLEV);
 
        batlev = (port4 & (BATLEV1 | BATLEV2)) >> 1; // normalize to 0-3
        TRACE("Battery level %d", batlev);
 
        HD66421_SET = 0x00;  // Control reg 1
        HD66421_USE = CR1_BASE | CR1_STBY;  // LCD On
 
        TRACE("Reverse Display");
        HD66421_SET = 0x00;  // Control reg 1
        HD66421_USE = CR1_BASE | CR1_RVRS;  // Reverse Video
 
        sleep(2000);
        HD66421_SET = 0x00;  // Control reg 1
        HD66421_USE = CR1_BASE & ~CR1_RVRS;  // Normal Video
 
        TRACE("done");
        return 0L;
 }
  • cybiko/registeraccess.txt
  • Last modified: 2009/11/27 17:54
  • by 127.0.0.1