chipKIT® Development Platform

Inspired by Arduino™

PWM and OLED on basic I/O shield.

Created Sat, 26 Dec 2015 23:30:28 +0000 by AZGO86


AZGO86

Sat, 26 Dec 2015 23:30:28 +0000

Hello, I am a student trying to complete a project for personal interest, and I am running into some difficulties. Through this site, I have found out how to modify the PWM channels to achieve a 12-bit resolution. Here is my code for that:

// Initialize Timer 2 T2CONCLR = T2_OFF; // Turn the timer off T2CON = T2_PS_1_8; // Set prescaler TMR2 = 0; // Clear the counter PR2 = 4096; // Set the period T2CONSET = T2_ON; // Turn the timer on

// Channel 1- White LEDS // Output Compare 1- PWM Pin 3 OC1R = 0; OC1CON = OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE; OC1CONSET = OC_ON;

// Channel 2- Red LEDS // Output Compare 2- PWM Pin 5 OC2R = 0; OC2CON = OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE; OC2CONSET = OC_ON;

// Channel 3- Blue LEDS // Output Compare 3- PWM Pin 6 OC3R = 0; OC3CON = OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE; OC3CONSET = OC_ON;

// Channel 4- Blue LEDS // Output Compare 4- PWM Pin 9 OC4R = 2048; OC4CON = OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE; OC4CONSET = OC_ON;

// Channel 5- Violet LEDS // Output Compare 5- PWM Pin 10 OC5R = 0; OC5CON = OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE; OC5CONSET = OC_ON;

The PWN works fine. The problem is, when I use the last output compare, my OLED screen stops working on the basic I/O shield. I need this for my project! Unfortunately, I don't see any other output compares that I can use. I don't know if this is a mistake in the way I am programming the board, or if this is just the way the I/O shield works. Does anyone know if it's possible to use all five PWN channels and the OLED at the same time?


tom21091

Mon, 18 Jan 2016 21:56:50 +0000

Hi AZGO86,

Sorry about the delay. I looked at the datasheet for the Basic IO Shield found here: [url]http://ww1.microchip.com/downloads/en/DeviceDoc/chipKIT%20Basic%20IO%20Shield_rm.pdf[/url] I noticed that pin 10 is wired to the OLED reset signal. This means that trying to use OC5, which is on pin 10 as well, will turn on and off the reset signal for the OLED. Unfortunately this means you cannot use OC5 at the same time as the OLED.

Hope this helps!

Tommy