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 (137093 times)
  2. FAT32 Library (70234 times)
  3. Network Ethernet Library (56120 times)
  4. USB Device Library (46434 times)
  5. Network WiFi Library (42056 times)
  6. FT800 Library (41384 times)
  7. GSM click (29111 times)
  8. mikroSDK (26560 times)
  9. PID Library (26489 times)
  10. microSD click (25486 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: 3822 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

Air Quality click

5

This example demonstrates usage of the Air Quality click board in mikroBUS form factor. Air Quality click is suitable for detecting poisonous gases that impact air quality in homes and offices. LCD shows detected concentration in PPM value.

[Learn More]

2x20W Amp click

6

2x20W Amp click carries the MAX9744 stereo class D audio power amplifier from Maxim Integrated. This click brings the Class AB sound performance with Class D efficiency. The perfect combination for your speakers.

[Learn More]

Relay click

0

Relay click is a dual relay Click board, which can be operated by the host MCU. This Click board offers an elegant and easy solution for controlling a wide range of high power applications.

[Learn More]