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 (137099 times)
  2. FAT32 Library (70236 times)
  3. Network Ethernet Library (56124 times)
  4. USB Device Library (46434 times)
  5. Network WiFi Library (42077 times)
  6. FT800 Library (41387 times)
  7. GSM click (29116 times)
  8. mikroSDK (26562 times)
  9. PID Library (26489 times)
  10. microSD click (25487 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

LTE IoT 11 click

0

LTE IoT 11 Click is a compact add-on board with an optimized global coverage module, as it supports a comprehensive set of bands required for global deployment. This board features the TX62-W, a global MTC module from Thales. It delivers global LTE-M, NB-IoT (NB1 and NB2) connectivity from a single SKU, and it is the first Thales product to adopt a revolutionary “Things” footprint. Besides, it integrates an embedded GNSS multi-constellation, state-of-the-art secure services, and more.

[Learn More]

Spectral 3 click

0

Spectral 3 click is a multispectral sensing device, which uses the state-of-the-art sensor IC for a very accurate near-IR (NIR) sensing.

[Learn More]

Proximity 11 click

5

Proximity 11 Click is a close-range proximity sensing Click board, equipped with the RPR-0521RS, a very accurate and power-efficient proximity and ambient Light Sensor with IrLED. It allows an accurate proximity detection for a maximum distance of 100mm.

[Learn More]