Being a bit new to MPLAB X and Harmony, I was wondering if anyone has any advice for getting the PPS and PWM working on a PIC32MX470F512H.
I've cut and pasted a bit of code from another example to configure the PWM, which looks okay to me. Although, saying that, the PPS code looks okay, too, and it obviously isn't as I get no output.
The aim is this: get a PWM output OC module 3, output via RB14.
Here's the relevant code I'm using:
- Code: Select all
PLIB_DEVCON_SystemUnlock(PORTS_ID_0);
PLIB_DEVCON_DeviceRegistersUnlock(DEVCON_ID_0, DEVCON_ALL_REGISTERS);
PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_OC3, OUTPUT_PIN_RPB14);
PLIB_PORTS_DirectionOutputSet(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_14 );
PLIB_DEVCON_DeviceRegistersLock(DEVCON_ID_0, DEVCON_ALL_REGISTERS);
PLIB_TMR_ClockSourceSelect(TMR_ID_2, TMR_CLOCK_SOURCE_PERIPHERAL_CLOCK);
PLIB_TMR_PrescaleSelect(TMR_ID_2, TMR_PRESCALE_VALUE_1);
PLIB_TMR_Mode16BitEnable(TMR_ID_2);
PLIB_TMR_Counter16BitClear(TMR_ID_2);
PLIB_TMR_Period16BitSet(TMR_ID_2, 2000);
PLIB_OC_TimerSelect(OC_ID_3, OC_TIMER_16BIT_TMR2);
PLIB_OC_ModeSelect(OC_ID_3, OC_TOGGLE_CONTINUOUS_PULSE_MODE);
PLIB_OC_FaultInputSelect(OC_ID_3, OC_FAULT_DISABLE);
PLIB_OC_BufferSizeSelect(OC_ID_3, OC_BUFFER_SIZE_16BIT);
PLIB_OC_Buffer16BitSet(OC_ID_3, 0);
PLIB_OC_PulseWidth16BitSet(OC_ID_3, 500);
/* Enable the OCMP module and start the timer */
PLIB_OC_Enable(OC_ID_3);
PLIB_TMR_Start(TMR_ID_2);
The PIC itself is running fine - a 16MHz crystal is driving it to 80MHz, and the ever famous "blink and LED" test works great. The above code compiles just fine, but my favorite scope is just showing me flat lines. This is in a very recent copy of MPLAB X, along with a very recent copy of XC32.
I can't tell what may be going on here, as most of the functions return void (no error codes)... before I went ahead and started going through what I can, into the assembler, etc, I thought I'd ask here to see if I've done anything obviously wrong.
Thanks for your patience, and any advice.