Tick Functions, Complex version! For the simple version, use nz_tick.h and nz_tick.c files. More...
#include "nz_tick.h"
Go to the source code of this file.
Macros | |
#define | getTick16bit_256ms() tick16Get_256ms() |
#define | tick16Update_256ms(tmr, msVal) (tmr += msVal) |
#define | tick8Get_1ms() (tick_val.v[0]) |
#define | tick8HasExpired_1ms(v) ((v - TICK.v[0]) & 0x80) |
#define | tick8HasExpired_16ms(v) ((v - ((UINT8)(tick_val.w[0]>>4))) & 0x80) |
#define | tick8Get_256ms() (tick_val.v[1]) |
Functions | |
WORD | tick16Get_256ms (void) |
BOOL | tick16HasExpired_256ms (WORD v) |
BYTE | tick8Get_16ms (void) |
Tick Functions, Complex version! For the simple version, use nz_tick.h and nz_tick.c files.
To use this module:
The system tick uses Timer 1, and has a period of 1ms. Each 1ms an interrupt is triggered, and the 32-bit system tick is incremented. To make code smaller and more efficient, various functions are available for using 8, 16 and 32-bit variables for implementing timers and delays. The 16-bit variants are the most efficient, and create the smallest code, seeing that the native data size for this CPU is 16-bits. The 8-bit variants use the least RAM. The 32-bit variables can create the longest delays.
Example default tick (16-bit, 1ms). Can be used for a maximum of 32,768 ms = 32 seconds delay. Requires 16-bit timer variable, which is the native data width of the processor! Produces fastest code.
Example using 8-bit, 16ms tick. Can be used for a maximum of 1,024ms = 1 second delay. Requires only 8-bit timer variable, but has small maximum delay of 1 second. Can use 8-bit 256ms timer for longer delay with 8 bit timer.
Example using 32-bit, 1ms tick. Can be used for a maximum of 4,294,967,296 ms = 1,193 hours = 49.7 Days delay. Requires 32-bit timer variable, generates more code, and is slower than other 8 and 16-bit functions.
Example using 16-bit, 256ms tick. Can be used for a maximum of 8,338 seconds = 2.3 Hours delay. Requires 16-bit timer variable, which is the native data width of the processor! Produces fastest code.
The following defines are used to configure this module, and should be placed in projdefs.h. Note that all items marked [-DEFAULT-] are defaults, and do not have to be placed in projdefs.h if they contain desired configuration! For details, see Project Configuration.
The software supplied herewith is owned by Modtronix Engineering, and is protected under applicable copyright laws. The software supplied herewith is intended and supplied to you, the Company customer, for use solely and exclusively on products manufactured by Modtronix Engineering. The code may be modified and can be used free of charge for commercial and non commercial applications. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license.
THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
File History
2012-08-08, David Hosken (DH):
#define getTick16bit_256ms | ( | ) | tick16Get_256ms() |
Alternative function name for tick16Get_256ms(). Gets 16-bit, 256ms tick.
#define tick16Update_256ms | ( | tmr, | |
msVal | |||
) | (tmr += msVal) |
Update the given timer to expire in the given multiple of 256ms. This timer has a 256ms base, so the given value will be multiplied by 256ms. For example, if 5 is given, it will cause the timer to expire in 5x256ms = 1.28 seconds
tmr | Timer to add the given milliseconds too |
msVal | Multiple of 256ms when timer will exprire! |
#define tick8Get_1ms | ( | ) | (tick_val.v[0]) |
Current system 8-bit tick. Has a resolution of 1ms. Has a maximum value of 128ms
#define tick8Get_256ms | ( | ) | (tick_val.v[1]) |
Second byte of current system 8-bit tick. Has a resolution of 256ms. Has a maximum value of 32,768ms = 32.7 seconds
#define tick8HasExpired_16ms | ( | v) | ((v - ((UINT8)(tick_val.w[0]>>4))) & 0x80) |
Will return true once the "8 bit tick" is > given value. Can have a maximum value of 1,024ms = 1 second
v | Given value to compare it |
#define tick8HasExpired_1ms | ( | v) | ((v - TICK.v[0]) & 0x80) |
Will return true once the "8 bit tick" is > given value. Can have a maximum value of 128ms
WORD tick16Get_256ms | ( | void | ) |
Get the current 16-bit, 256ms Tick. Has a maximum value 8,338 seconds = 2.3 Hours
BOOL tick16HasExpired_256ms | ( | WORD | v) |
Will return true once the 16 bit(256ms) tick is > given value. Tick is a 256ms counter. Can have a maximum value of 8,338 seconds = 2.3 Hours
v | Given value to compare it |
BYTE tick8Get_16ms | ( | void | ) |
Get the current 8-bit, 16ms Tick. Has a maximum value of 2,048ms = 2 seconds