chipKIT® Development Platform

Inspired by Arduino™

Problems using peripherals such as OC modules.

Created Mon, 04 Nov 2013 14:12:25 +0000 by winchymatt


winchymatt

Mon, 04 Nov 2013 14:12:25 +0000

Hi, I'm new to chipKit and the Arduino way, but very familiar with the PIC range of processors.

I have my UNO32 up and running with various examples, but already now need to start running hardware PWN capture on the input capture pins. So I found some examples on-line that use the OpenOC1() functions, but I have not been able to find any reference material for these peripheral functions.

Is there a list of available peripheral functions? if so where?

Also I read that in order to use this function I will need to include the "outcompare.h" file, but I have to feed in the full path in order for the compiler to find this, such as:

#include "/home/user/bin/mpide-0023-linux32-20130817-test/hardware/pic32/compiler/pic32-tools/pic32mx/include/peripheral/outcompare.h"

Is this correct? should I need the full path?


dangeljs

Mon, 04 Nov 2013 15:32:09 +0000

You shouldn't need to include the "outcompare.h", just include <PLIB.h> and that should include all peripheral libraries. You can google search PIC32 and PLIB to get examples, or just search microchip.com.


majenko

Mon, 04 Nov 2013 15:33:05 +0000

For hardware PWM just use the "analogWrite()" function on any of the PWM enabled IO pins:

analogWrite(3, 173);

The first parameter is the pin number, the second is the duty cycle from 0 to 255.


winchymatt

Mon, 04 Nov 2013 16:11:43 +0000

You shouldn't need to include the "outcompare.h", just include <PLIB.h> and that should include all peripheral libraries. You can google search PIC32 and PLIB to get examples, or just search microchip.com.

So is the chipKit IDE using the microchip C compiler and libraries? If so this is a useful bit of info I haven't seen on any of the "getting started" type pages as yet.


dangeljs

Mon, 04 Nov 2013 16:26:57 +0000

I'm not sure that it is required for the MPIDE, but the library is made available and I have used several of the functions.

As Majenko pointed out, if you just want to use a generic PWM out the Analog write is available and won't require including the library. If you want to use more of the functionality of the OC module then the PLIB is the way to go.


winchymatt

Mon, 04 Nov 2013 16:36:54 +0000

I'm not sure that it is required for the MPIDE, but the library is made available and I have used several of the functions. As Majenko pointed out, if you just want to use a generic PWM out the Analog write is available and won't require including the library. If you want to use more of the functionality of the OC module then the PLIB is the way to go.

Yes I'm going to use the OC module and the CN module for PWM capture and generation.

cheers.