101-0412 Rabbit Semiconductor, 101-0412 Datasheet - Page 83

no-image

101-0412

Manufacturer Part Number
101-0412
Description
INTERFACE PROG 12KEY DISP OP6700
Manufacturer
Rabbit Semiconductor
Datasheet

Specifications of 101-0412

Module/board Type
Single Board Computer Module
For Use With/related Products
OP6700
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
The numbers in the left margin are reference indicators, and are not a part of the code.
Load and run the program. Note that LED2 flashes once per second. Push button SW1
several times and note how LED1 is toggled.
The flashing of LED2 is performed by the costatement starting at the line marked (2). Cos-
tatements need to be executed regularly, often at least every 25 ms. To accomplish this, the
costatements are enclosed in a
to describe a style of real-time programming in which most operations are done in one loop.
The while loop starts at (1) and ends at (7).
User’s Manual
main() {
(1)
(2)
(3)
(4)
(5)
(6)
(7)
}
int vswitch;
WrPortI(PDDDR, &PDDDRShadow, 0x03); // set port D bits 0-1 as outputs
WrPortI(PDDCR, &PDDCRShadow, 0x00); // set port D to not open drain mode
vswitch = 0;
while (1) {
}
}
// First task will flash LED4 for 200 ms once per second.
// Second task - debounce SW1 and toggle vswitch
costate {
}
// make LED1 agree with vswitch
// end of main
costate {
BitWrPortI(PDDR, &PDDRShadow, vswitch, 0);
// end of while loop
BitWrPortI(PDDR, &PDDRShadow, 0xFF, 1);
BitWrPortI(PDDR, &PDDRShadow, 0x00, 1);
waitfor(DelayMs(800));
waitfor(DelayMs(50));
if(!BitRdPortI(PDDR, 2))
vswitch = !vswitch;
while (1) {
}
waitfor(DelayMs(200));
if (!BitRdPortI(PDDR, 2)) abort; // if button not down skip out
waitfor(!BitRdPortI(PDDR, 2));
waitfor(DelayMs(200));
if (!BitRdPortI(PDDR, 2))
break;
while
// state of virtual switch controlled by button S1
loop. The term
// if button still up break out of while loop
// end of costate
abort; // if button not still down exit
// toggle since button was down 50 ms
// initialize virtual switch as off
// endless loop
while
// wait 50 ms
// wait for button to go up
// wait additional 200 ms
loop is used as a handy way
// turn LED on
// turn LED off
// wait 800 ms
// wait 200 ms
79

Related parts for 101-0412