News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

PWM in PIC24FJ256GA705.

Started by Gamboa, Apr 18, 2023, 06:49 AM

Previous topic - Next topic

Gamboa

Hi,

I've been doing some tests with a PIC24FJ256GA705 with a PIC24FJ256GA7 Curiosity board. I have learned some things like:
1.- Handling PPS.
2.- Use USART1 and 2 with interrupt.
3.- Handle TMR2 and TMR3 with interruption.
4.- Other things like turning on an LED and reading a button.

Now I am working on making the PWM work through the B2 port but there is no way. Of all the tests carried out, no signal appears. I have also tried for B0. The ports work fine because if I put them in digital mode they switch fine. So many registers with so many options make me a mess that I don't quite understand.

I have tried different values for the period and the duty cycle of the PWM but nothing comes out of PIN B2. The problem must be in the configuration of one of the PWM registers. I attach the program.

I have set the TRISB.2 register as output. I have configured the PPS RP2 as OC1 output and then I have configured channel 1 MCCP registers according to an application note in the manual "30003035b.pdf". In the attached .bas program there are two includes:
"ConfigFuses.inc" sets the microcontroller fuses for 8MHz FRC oscillator.
In the file "ConfigPines.inc" the registers of the pins are set and the PPS are handled.
In the .BAS file there is a general initialization procedure for everything, it is called "Inicializar()". The initialization of the OC1 module is done in "OC1_Inicializar()".

I have worked with a DSPIC33 with PWM and had no problem getting it up and running. In it the PWM was associated with the TMR2. But the PIC24FJ256GA705 has its own timer registers associated with the MCCP modules and I'm having a hard time getting them to work.

If anyone has worked with something like this and can point me to some information, I would appreciate it.


Regards,
Gamboa

Long live for you