Published:2011/8/14 21:04:00 Author:Phyllis From:SeekIC
By Lourens le Grange
Figure 4 gives the basics of a timer interrupt service routine (which is your code) containing a call to the subroutine SCHEDOO. The following execution rates (in ms) are available for Time Tasks:
10,20,40,50, 100,200
The time task scheduler uses a 20-entry look-up table to save the task timing information. Every 10 ms the scheduler routine fetches the next entry in this table and OR it to the RAM location holding the 8 TIME TASK request bits. The entries in the look up table are generated at assembly time using information from the file xextaskl .def. The source code for PICXEX18 is contained in the following three files:
Xextaskl.def
Xexl 8tsk.mac
Xexl 8mak.asm
Xextask1. def
This is the only file that requires modification. The file is used to define the following:
Number of CYCLE TASKS.
Label at the start of each TIME TASK.
Execution rate for each TIME TASK.
Bias time for each TIME TASK.
Xex18tsk.mac
Source code for task control macros.
Xex18mak.asm
This file contains the code for PICXEX18. When this file is assembled it will generate the CYCLE and TIME TASK loops and the scheduler table.
Using PICXEX18
The archive file 040149-11.zip you can download for free from our website contains all the source code required for the following example application to demonstrate the use of PICXEX18. To generate the .HEX file simply assemble the file ELEKTOR.ASM using the MPASM assembler (free from Microchip). The latter file contains the directives to include the other files required. The application contains two Cycle Tasks and two Time Tasks.
Time Task 1 is a pulse generator. It will pulse the bit ’Pulse,0’ at a rate of one pulse every 400 ms.
Time Task 2 is a sawtooth generator. It will cause the byte ’Saw’ to ramp up in 2550 ms to a value of 255 and then reset to 0. On every reset the bit ’Zero,0’ is set (it will be reset by the active step of the sequence).
Cycle Task 1 is a pulse counter. Every rising edge on the bit ’Pulse,0’ will increment the 16"bil value ’Count’.
Cycle Task 2 is a sequence with three steps. The sequence will remain in a step until the bit ’Zero,0’ is set. This bit v/ill be cleared and the sequence advance to the next step. When in the third step and bit ’Zero,0’ is set, then the sequence will revert back to step number 1. The byte ’StepNr’ indicates the number of the current step. Once you have assembled this application, it can be tested by running it using the MPLAB simulator. To verify that the two time tasks are in fact being executed at the required rates of 200 and 40 ms, use a breakpoint at the tasks’s starting point PULSE_GEN and RAMP_GEN) and MPLAB’s Stopwatch function to see how long it takes between executions. The application was programmed into a PIC1 8F452 clocked at 8 MHz.
PICWin8
When testing an application where a few things are happening at the same time it is very helpful to be able to see how the different signals are behaving. In the ELEK-TOR.ASM file, right after the setting of the configuration bits, you’ll find a statement to set the assembler variable ’PicWin’. This is used to include the assembly code for an interrupt service routine for the UART to handle the data exchange with a PC utility to monitor and modify variables in the PIC. The screenshot of the PicWin monitor in action, Figure 6, shows trend traces of the four variables of our application, which, as you can see, is functioning as required.
The ’PicWin’ monitor has the following features:
- VB6 application
- Baud rate 9600 (fixed)
- Can display & trend up to 6 values simultaneously
- 4 fields supplied for commands (modify PIC RAM locations).
- Each trend buffer = 800 samples. Display = 400 samples with scroll
- Data types: bit, byte, word, Fpoint
- Adjustable scan rate
- Performance: the screenshot shows four traces scanned at 87 ms. Each trace was shifted to get a better view of what’s happening.
A user guide and setup instructions for the PicWin monitor may be found in a text file included in the zip archive for this project. Happy Pic’king!
Reprinted Url Of This Article: http://www.seekic.com/blog/project_solutions/2011/08/14/PICXEX18_AND_PlCWIN8__Operating_System_and_Monitor_for_PIC_Microcontrollers__(3).html
Print this Page | Comments | Reading(687)
Author:Ecco Reading(30175)
Author:Ecco Reading(3461)
Author:Ecco Reading(3181)
Author:Ecco Reading(3661)
Author:Ecco Reading(5231)
Author:Ecco Reading(3248)
Author:Ecco Reading(3390)
Author:Ecco Reading(3530)
Author:Ecco Reading(3935)
Author:Ecco Reading(3707)
Author:Ecco Reading(3677)
Author:Ecco Reading(3714)
Author:Ecco Reading(6028)
Author:Ecco Reading(3692)
Author:Ecco Reading(4478)