no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | cybiko:registeraccess [2009/11/27 17:54] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | You can access the memory locations but you | ||
+ | obviously couldn' | ||
+ | used the green LED in many of my projects in bytecode. | ||
+ | exp: | ||
+ | <code c> | ||
+ | # | ||
+ | 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: | ||
+ | <code c> | ||
+ | # | ||
+ | |||
+ | | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # | ||
+ | # | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | void togglePort(long port, short mask, char *text) { | ||
+ | TRACE(" | ||
+ | (*(char *)port) |= mask; | ||
+ | sleep(2000); | ||
+ | |||
+ | TRACE(" | ||
+ | (*(char *)port) &= ~mask; | ||
+ | sleep(2000); | ||
+ | } | ||
+ | /** | ||
+ | * Main entry point | ||
+ | */ | ||
+ | long main(int argc, char* argv[], bool start) | ||
+ | { | ||
+ | char port4; | ||
+ | char batlev; | ||
+ | init_module( & | ||
+ | |||
+ | TRACE(" | ||
+ | sleep(1000); | ||
+ | |||
+ | // NOTE: If you have the cybiko running on MAINS | ||
+ | // then you will not see the red LED toggle. | ||
+ | togglePort(PORT2, | ||
+ | togglePort(PORT2, | ||
+ | togglePort(PORT2, | ||
+ | |||
+ | port4 = (*(char *)PORT4) & PORT4_MASK; | ||
+ | TRACE(" | ||
+ | |||
+ | batlev = (port4 & (BATLEV1 | BATLEV2)) >> 1; // normalize to 0-3 | ||
+ | TRACE(" | ||
+ | |||
+ | HD66421_SET = 0x00; // Control reg 1 | ||
+ | HD66421_USE = CR1_BASE | CR1_STBY; | ||
+ | |||
+ | TRACE(" | ||
+ | HD66421_SET = 0x00; // Control reg 1 | ||
+ | HD66421_USE = CR1_BASE | CR1_RVRS; | ||
+ | |||
+ | sleep(2000); | ||
+ | HD66421_SET = 0x00; // Control reg 1 | ||
+ | HD66421_USE = CR1_BASE & ~CR1_RVRS; | ||
+ | |||
+ | TRACE(" | ||
+ | return 0L; | ||
+ | } | ||
+ | </ | ||
+ | {{tag> |