background image

Getting Started Manual

15

The statement at (3) waits for a time delay, in this case 200 ms.  The costatement is being 
executed on each pass through the big loop.  When a 

waitfor

 condition is encountered 

the first time, the current value of 

MS_TIMER

 is saved and then on each subsequent pass 

the saved value is compared to the current value.  If a 

waitfor

 condition is not encoun-

tered, then a jump is made to the end of the costatement (4), and on the next pass of the 
loop, when the execution thread reaches the beginning of the costatement, execution 
passes directly to the 

waitfor

 statement.  Once 200 ms has passed, the statement after 

the waitfor is executed.  The costatement has the property that it can wait for long periods 
of time, but not use a lot of execution time.  Each costatement is a little program with its 
own statement pointer that advances in response to conditions.  On each pass through the 
big loop, as little as one statement in the costatement is executed, starting at the current 
position of the costatement’s statement pointer.  Consult the Dynamic C Reference Man-
ual
 for more details.

The second costatement in the program debounces the switch and maintains the variable 

vswitch

.  Debouncing is performed by making sure that the switch is either on or off for 

a long enough period of time to ensure that high-frequency electrical hash generated when 
the switch contacts open or close does not affect the state of the switch.  The 

abort

 state-

ment is illustrated at (5).  If executed, the internal statement pointer is set back to the first 
statement within the costatement, and a jump to the closing brace of the costatement is 
made.

At (6) a use for a shadow register is illustrated. A shadow register is used to keep track of 
the contents of an I/O port that is write only - it can’t be read back. If every time a write is 
made to the port the same bits are set in the shadow register, then the shadow register has 
the same data as the port register. In this case a test is made to see the state of the LED and 
make it agree with the state of vswitch. This test is not strictly necessary, the output regis-
ter could be set every time to agree with vswitch, but it is placed here to illustrate the con-
cept of a shadow register.

To illustrate the use of snooping, use the watch window to observe 

vswitch

 while the 

program is running.  Add the variable 

vswitch

 to the list of watch expressions.  Then 

toggle 

vswitch

 and the LED.  Then type 

<ctrl-U>

 to observe 

vswitch

 again.

3.4  Advantages of Cooperative Multitasking

Cooperative multitasking, as implemented with language extensions, has the advantage of 
being intuitive.  Unlike preemptive multitasking, variables can be shared between differ-
ent tasks without having to take elaborate precautions.  Sharing variables between tasks is 
the greatest cause of bugs in programs that use preemptive multitasking.  It might seem 
that the biggest problem would be response time because of the big loop time becoming 
long as the program grows.  Our solution for that is a device caused slicing that is further 
described in the Dynamic C Reference Manual.

Summary of Contents for 2000

Page 1: ...Rabbit 2000 Microprocessor Development Kit Getting Started 010118 D...

Page 2: ...nst consequences resulting from system failure is the buyer s responsibility This device is not approved for life support or medical systems All Rabbit Semiconductor products are 100 percent functiona...

Page 3: ...3 2 4 Watching Variables Dynamically 12 3 2 5 Summary of Features 12 3 3 Cooperative Multitasking 13 3 4 Advantages of Cooperative Multitasking 15 4 Software Reference 17 4 1 More About Dynamic C 17 4...

Page 4: ...Rabbit 2000 Development Kit...

Page 5: ...of the basics of operating a software program and editing files under Windows on a PC Knowledge of basic assembly language and architecture for controllers For a full treatment of C refer to the follo...

Page 6: ...ng Board includes various accessories such as pushbutton switches LEDs and a beeper In addition you can add your own circuitry Programming cable This is a cable that is used to connect your PC serial...

Page 7: ...yping Board that includes pushbutton switches LEDs and a beeper can be plugged into the Jackrabbit board By writing pro grams that run on the Jackrabbit board you can flash the LEDs beep the beeper an...

Page 8: ...s whenever a break point is set in the program This can crash fast interrupt routines that are running while you stop at a breakpoint or single step the program Flash or RAM is selected on the Options...

Page 9: ...4 Rabbit 2000 Development Kit...

Page 10: ...ely 10 megabytes of free space on your hard disk The software can be installed on your C drive or any other convenient drive 2 2 Getting Hooked Up Figure 1 below shows an overview of how the serial an...

Page 11: ...ND RXC TXC PC1 PC3 PC5 PC7 AGND DA1 PD1 PD3 PD5 PD7 GND 485 VCC SM1 STAT VBAT GND Z World Inc GND PA0 PA2 PA4 PA6 GND PB0 PB2 PB4 PB6 WDO GND PE6 PE4 PE2 PE0 HV0 HV2 K GND VCC PA1 PA3 PA5 PA7 GND PB1...

Page 12: ...VIN positive voltage is the middle pin and GND is available on both ends of the three pin header J1 3 Plug in the wall transformer The Jackrabbit board and the Prototyping Board are ready to be used...

Page 13: ...y the different COM ports in the OPTIONS menu until you find the one you are connected to If you can t get Dynamic C to recognize the target on any port then the hookup may be wrong or the COM port is...

Page 14: ...sample programs are listed in Table 1 The first five sample programs provide a step by step introduction to the Jackrabbit board Additional sample programs illustrate more advanced topics Each sample...

Page 15: ...evelopment Board should start flashing if everything went well If this doesn t work review the follow ing points The target should be ready which is indicated by the message BIOS successfully compiled...

Page 16: ...to single step Each time the F8 key is pressed the cursor will advance one statement When you get to the for j 0 j statement it becomes impractical to single step further because you would have to pre...

Page 17: ...ble to view variables while the program is running Use the F9 key to compile and run DEMOJR2 C Now type ctrl W to open the watch window and add the watch expression k to the top of the list of watch e...

Page 18: ...on is evaluated as if it were in a separate function with no local variables 3 3 Cooperative Multitasking Cooperative multitasking is a convenient way to perform several different tasks at the same ti...

Page 19: ...itfor BitRdPortI PBDR 2 wait for button to go up waitfor DelayMs 200 wait for 200 milliseconds if BitRdPortI PBDR 2 break if button up break end of while 1 end of costatement make LED agree with vswit...

Page 20: ...bort state ment is illustrated at 5 If executed the internal statement pointer is set back to the first statement within the costatement and a jump to the closing brace of the costatement is made At 6...

Page 21: ...16 Rabbit 2000 Development Kit...

Page 22: ...le debugging is being done because it is more flexible than flash memory Dynamic C does not use include files rather it has libraries which are used for the same purpose that is to supply function pro...

Page 23: ...t E bits 0 3 for digital output and starts up the pulse width modulation routines for the A D and D A channels Note that these routines can consume up to 20 of the CPU s processing power the routines...

Page 24: ...oth D A channels are used A voltage is selected by giving a value from 0 to 1024 to the driver corresponding roughly to 0 1 V to 3 5 V on DA0 Because of the PWM interrupt frequency the PWM driver can...

Page 25: ...y the driver and cause fluctuations in the voltage out puts Avoid using serial communications or printf statements during portions of your program where the voltage must remain steady Also be aware th...

Page 26: ...only on the Jackrabbit An integer between 0 and 1024 will be returned in value corresponding to a voltage obtained if output channel DA0 was set to that value If a value is found but the voltage has...

Page 27: ...llowing groups Open and Close Functions Non Cofunction Blocking Input Functions Non Cofunction Blocking Output Functions Single User Cofunction Input Functions Single User Cofunction Output Functions...

Page 28: ...able Parameters None Return Value An integer with return character in the low byte No character is represented by a return of 1 int serXread void data int length unsigned long tmout Reads a block of c...

Page 29: ...te Return Value 1 for success 0 if the character could not be written to the port int serXputs char s Calls serXwrite s strlen s Parameters s Null terminated character string source to write to the se...

Page 30: ...ecution and only returns control to the following statement in its own costatement block when it completes Parameters data Destination data structure The user must ensure data is allocated for at leas...

Page 31: ...Parameters c Character to write to the serial port Return Value None scofunc void cof_serXputs char s Writes a null terminated character string to the serial port yielding to other tasks when unsucces...

Page 32: ...ze of 31 will be used and a compiler warn ing will be given When using cofunctions smaller buffer sizes can yield more frequently to other tasks but have the risk of a large input data stream overrunn...

Page 33: ...becoming full int serXwrFree Calculates the free space in the serial port transmit buffer Parameters None Return Value The number of characters the serial port transmit buffer can accept before becom...

Page 34: ...de A D input input range 0 V to 3 V 10 bit resolution 8 bit accuracy average acquisition time 150 ms 165 ms maximum with 14 7 MHz clock Analog Outputs Two filtered and buffered PWM outputs Digital Out...

Page 35: ...30 Rabbit 2000 Development Kit...

Page 36: ...Getting Started Manual Schematics...

Page 37: ...B DRAWING CONTENT APPROVALS INITIAL RELEASE SIGNATURES 2900 SPAFFORD ST DAVIS CA 95616 530 757 4616 THIS DOCUMENT APPEND THE FOLLOWING DOCUMENTS WHEN CHANGING ECO APPROVAL APPROVAL CONTROL DOCUMENT DA...

Page 38: ...B NONE B NONE...

Page 39: ...B NONE B NONE...

Page 40: ...B DRAWING CONTENT APPROVALS INITIAL RELEASE SIGNATURES 2900 SPAFFORD ST DAVIS CA 95616 530 757 4616 THIS DOCUMENT APPEND THE FOLLOWING DOCUMENTS WHEN CHANGING ECO APPROVAL APPROVAL CONTROL DOCUMENT DA...

Page 41: ...B NONE B NONE...

Page 42: ...ALS INITIAL RELEASE DRAWING CONTENT B 2900 SPAFFORD ST DAVIS CA 95616 ZWORLD DATE NONE 530 757 4616 THIS DOCUMENT APPEND THE FOLLOWING DOCUMENTS WHEN CHANGING ECO APPROVAL APPROVAL CONTROL DOCUMENT DA...

Page 43: ......

Reviews: