![]() |
Fraise
2.1
FRAmework for Interfacing Software and Electronics
|
Implements 8channels(max) 10bits 100Hz(max) software PWM. More...
Implements 8channels(max) 10bits 100Hz(max) software PWM.
Example : main.c
config.h
Settings to put in config.h | |
Define in config.h the wanted pins: #define SOFTPWM0 K1 (replace K1 by the pin you want for softpwm channel 0)
#define SOFTPWM1 K2 (replace K2 by the pin you want for softpwm channel 1)
(...)
The following parameters can be overloaded: | |
#define | SOFTPWM_TIMER |
Timer to be used by the softpwm module (only 1, 3 or 5 ; default: 5). | |
#define | SOFTPWM_MAX_VALUE |
default 1023. | |
#define | SOFTPWM_TICK_US |
default 5 ; PWM frequency will be 1 / (SOFTPWM_MAX_VALUE * SOFTPWM_TICK_US) | |
#define | SOFTPWM_INTPRI |
default 1 (high priority). | |
Initialization | |
void | softpwmInit () |
Init the module in setup() | |
Utilities | |
void | softpwmSet (unsigned char chan, unsigned int val) |
Set the value of a channel. | |
unsigned int | softpwmGet (unsigned char chan) |
Get the current value of a channel. | |
Interrupt routine | |
void | softpwmHighInterrupt (void) |
Module high interrupt routine, must be called by the highInterrupts() user defined function. | |
void | softpwmLowInterrupt (void) |
Module low interrupt routine, must be called by the lowInterrupts() user defined function. | |
Receive function | |
void | softpwmReceive () |
Module receive function, to be called by the fraiseReceive() user defined function. More... | |
void softpwmReceive | ( | ) |
Module receive function, to be called by the fraiseReceive() user defined function.
The first byte of the message represents the channel (0-7), the 2 next bytes are the 16 bit new pwm value.