TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (137081 times)
  2. FAT32 Library (70222 times)
  3. Network Ethernet Library (56094 times)
  4. USB Device Library (46411 times)
  5. Network WiFi Library (42029 times)
  6. FT800 Library (41375 times)
  7. GSM click (29109 times)
  8. mikroSDK (26555 times)
  9. PID Library (26487 times)
  10. microSD click (25483 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

PWM 2 click

Rating:

5

Author: MIKROE

Last Updated: 2018-09-10

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: PWM

Downloaded: 3818 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.

No Abuse Reported

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".

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

PWM 2 click

PWM 2 click

Native view of the PWM 2 click board.

View full image
PWM 2 click

PWM 2 click

Front and back view of the PWM 2 click board.

View full image

Library Description

The library carries all necessary functions for complete control over PWM 2 click.

Key functions:

  • void pwm2_togglePhaseShift() - Functions for toggle phase shift
  • uint8_t pwm2_setChannel(uint8_t nChannel, uint16_t width,uint8_t correction) - Function for set channel
  • void pwm2_Inits() - Function for initialization of the chip

Example description

The application is composed of three sections:

  • System Initialization -  PWM, SPI and CS pin are initialized PWM is used as a PWMCK signal for the PWM2 click board. SPI is used as a serial data in. CS pin is used as a LDIBLANK signal.
  • Application Initialization -PWMCK signal is set to 15mhz and to give a 50% duty cycle. The PWM2 click channels are initialized to 75% duty cycle, and the phase shift is toggled on.
  • Application Task - (code snippet) - the first 10 PWM2 click channels are switched back and forth from 25% duty cycle to 100% duty cycle every second.
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:

  • PWM

Additional notes and information

Depending on the development board you are using, you may need USB UART clickUSB 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.

ALSO FROM THIS AUTHOR

LSM303AGR click

0

LSM303AGR click is a magnetometer and accelerometer device, capable of sensing both the magnetic and gravitational field along three orthogonal axes. It uses the LSM303AGR from STMicroelectronics, an integrated MEMS IC with plenty of features that allow accurate and reliable sensing, even in presence of foreign objects made of iron and similar materials that exhibit ferromagnetic behavior. An extensive interrupt engine can be programmed to generate an interrupt signal for free-falling events, motion detection, and magnetic field detection. The Click board™ can sense the magnetic field in the range of ±50 G (gauss) and ±2g, ±4g, ±8g, and ±16g selectable ranges for the full-scale acceleration detection (gravity force).

[Learn More]

GSM click

0

GSM click is the easiest way to add GSM/GPRS communication to your device. The click features Telit's GL865-QUAD. GSM click runs either on 3.3V or 5V power supply and communicates with the target microcontroller via UART interface.

[Learn More]

CO click

5

This example demonstrates usage of the CO click board in mikroBUS form factor. This CO sensor is suitable for gas detecting equipment for Carbon Monoxide (CO). LCD shows PPM value of Carbon Monoxide (CO) concentration.

[Learn More]