We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2018-09-10
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: PWM
Downloaded: 4302 times
Not followed.
License: MIT license
PWM 2 click offers 48 independently controlled PWM channels, available over the onboard headers, perfectly suited for driving LEDs.
Do you want to subscribe in order to receive notifications regarding "PWM 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "PWM 2 click" changes.
Do you want to report abuse regarding "PWM 2 click".
Library Description
The library carries all necessary functions for complete control over PWM 2 click.
Key functions:
void pwm2_togglePhaseShift()
- Functions for toggle phase shiftuint8_t pwm2_setChannel(uint8_t nChannel, uint16_t width,uint8_t correction)
- Function for set channelvoid pwm2_Inits()
- Function for initialization of the chipExample description
The application is composed of three sections:
void applicationInit()
{
uint8_t i;
pwm2_spiDriverInit( (T_PWM2_P)&_MIKROBUS1_GPIO, (T_PWM2_P)&_MIKROBUS1_SPI );
Delay_ms( 100 );
//PWMCK setup:
period_PWM = PWM_TIM2_Init(_PWM2_CLOCK_15_MHZ);
PWM_TIM2_Set_Duty(period_PWM/2,_PWM_NON_INVERTED,_PWM_CHANNEL1);
PWM_TIM2_Start(_PWM_CHANNEL1, &_GPIO_MODULE_TIM2_CH1_PA0);
//end of PWMCK setup
dutyMode = 1;
pwm2_Inits();
//setting all 48 PWM2 channels on the PWM2 click to 75% duty
for(i = 1; i < 49; i++)
{
pwm2_setChannel(i,_PWM2_50_PERCENT_DUTY,_PWM2_NO_CORRECTION);
}
pwm2_togglePhaseShift();
}
Other MikroElektronika libraries used in the example:
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.