Run PWM2 in PIC18f46k80

Fully featured PIC compilers available on Windows, Linux, and macOS.
Post Reply
Author
Message
irsmeco
Posts: 3
Joined: 20 Mar 2011 11:50

Run PWM2 in PIC18f46k80

#1 Post by irsmeco » 28 Jun 2023 09:14

Hi everyone
I am using 18f46k80 MCU. I was able to set up interrupts and digital ports, but pwm won't start up. Please help me to run PWM2
A part of the program is as follows

trisA=%00101011
latA=%00101011
TRISE=0
LATE=0
TRISB=%11110100
LATB=%00000000
TRISC =%00000000
PORTC =%00000100
TRISD =%00000000
LATD =%00000000
CTMUCONH = %00000000
CTMUCONL = %00000000
CTMUICON = %00000000
ANCON0=%00101001
ANCON1=%00000000
ODCON=%00001000
T1GCON=0
SSPCON1=0
RCON=%10000000
intcon=%11001000
intcon2=%00000001
intcon3=%00000000
CCPTMRS.b1=1
IOCB=%11110000
ADCON0=%00000001
REFOCON=%00110000
PSPCON =%00000000
WDTCON =%00000001
PMD0=%11101111
PMD1=%11011110
PMD2=%00001111
PWM2_Init(5000)
PWM2_START
T4CON=%00000111
ccp2con=%00001100

irsmeco
Posts: 3
Joined: 20 Mar 2011 11:50

Re: Run PWM2 in PIC18f46k80

#2 Post by irsmeco » 02 Jul 2023 10:38

The code works correctly in the Proteus emulator, but in the real circuit, no changes occur in the ccp2 ports and other ports.
I need urgent help

irsmeco
Posts: 3
Joined: 20 Mar 2011 11:50

Re: Run PWM2 in PIC18f46k80

#3 Post by irsmeco » 03 Jul 2023 12:53

Hi
Unfortunately, no one helped me during this time. But finally I was able to solve this problem. I write this comment to help others
Set the value to 0 in the ODCON register and set CCPTMRS.b1=0. pwm uses timer 2

Post Reply

Return to “PIC AI compilers”