TOP Contributors

  1. MIKROE (2650 codes)
  2. Alcides Ramos (350 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 (136538 times)
  2. FAT32 Library (69734 times)
  3. Network Ethernet Library (55842 times)
  4. USB Device Library (46178 times)
  5. Network WiFi Library (41801 times)
  6. FT800 Library (40989 times)
  7. GSM click (28922 times)
  8. PID Library (26384 times)
  9. mikroSDK (26281 times)
  10. microSD click (25298 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: 3738 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

ADC 21 click

0

ADC 21 Click is a compact add-on board that converts an analog voltage into a digital representation. This board features the ADC1283, a low-power, eight-channel pure CMOS 12-bit analog-to-digital converter from STMicroelectronics. The ADC1283 is specified for conversion from 50ksps to 200ksps. Its architecture is based on a successive approximation register with an internal track-and-hold cell. It features eight single-ended multiplexed inputs, where the output serial data is straight binary and SPI-compatible.

[Learn More]

Thermostat 4 click

5

Thermostat 4 Click is complete solution that senses the temperature of a physical system and can performs actions so that the system's temperature is maintained near a desired setpoint.

[Learn More]

13DOF click

5

13DOF Click is an advanced 13-axis motion tracking Click board, which utilizes three different sensor ICs onboard: BME680, a digital gas, humidity, pressure and temperature sensor and BMM150, a geomagnetic sensor and a BMI088, small, versatile 6DoF sensor module.

[Learn More]