![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
JAM2014
Joined: 24 Apr 2014 Posts: 138
|
PWM on a 18F45K50 |
Posted: Wed Mar 30, 2016 4:35 pm |
|
|
Hi All,
I'm trying to get a PWM output on an 18F45K50 device. I recently updated a design from the 18F25K50, and PWM worked fine on that device, but not this one! I'm expecting the PWM to show up on the 'CCP1' pin, which pin #40 on the 18F45K50 device (44 lead TQFP). On the 18F25K50, I do see the PWM output on pin #13 (28 lead SOIC).
Compiler version v5.050
Test Program:
Code: |
#include <18F45K50.h>
#fuses HSH,PLL3X,NOWDT,NOPROTECT,NOLVP,NODEBUG,NOFCMEN,CPUDIV3
#use delay(crystal=16MHz, clock=16MHz, USB_FULL)
//Note the 16MHz becomes 48MHz for the USB peripheral by the PLL3X fuse. The processor runs
//at 16MHz by the CPUDIV3 fuse!
//-----< General Program Defines >-----
#define Pwr_LED Pin_B0 // Power LED
//======================================
void main(void)
{
int8 iIndex;
// Here we blip the Power LED at power-up to show that the interface is working
for ( iIndex = 0 ; iIndex < 4 ; iIndex++ )
{
output_high(PWR_LED);
delay_ms(250);
output_low(PWR_LED);
delay_ms(250);
}
// Here we leave the Power LED ON
output_high(PWR_LED);
// Here we setup the PWM output...
// This should output a PWM pulse train on CCP1 (Pin 13 of 18F25K50 or Pin 40 of 18F45K50)...
setup_ccp1(CCP_PWM_L_L);
setup_timer_2(T2_DIV_BY_16, 255, 1);
set_pwm1_duty(128); // 50% duty cycle
while(1){} //Stop here!!!
}
|
The processor is running, and at the correct speed! My LED flashes correctly, and I can send data out the UART.
Any help would be appreciated!
Jack |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 30, 2016 6:20 pm |
|
|
Quote: |
I'm expecting the PWM to show up on the 'CCP1' pin, which pin #40 on
the 18F45K50 device (44 lead TQFP). |
I looked at the 18F45K50 data sheet, and the table in the Device Overview
section doesn't say anything about pin 40 of the TQFP package being a
PWM output. It's only RD2 or AN22.
http://ww1.microchip.com/downloads/en/DeviceDoc/30000684B.pdf
Code: |
40-pin 40-pin 44-pin Analog
PDIP UCFN TQFP
RD2 - - 21 36 40 AN22 |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19378
|
|
Posted: Thu Mar 31, 2016 12:49 am |
|
|
It'll be on pin 36 on his package..... |
|
![](templates/subSilver/images/spacer.gif) |
JAM2014
Joined: 24 Apr 2014 Posts: 138
|
|
Posted: Thu Mar 31, 2016 8:59 am |
|
|
Hi All,
Argh!!! After a brief search, the PWM output was found on pin 36......
Now, to go find the guy who generated the schematic decal and PCB......
Lesson learned, 'trust, but verify!'......
Thanks all!
Jack |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19378
|
|
Posted: Thu Mar 31, 2016 10:53 am |
|
|
The 'classic' I'm afraid, is using a PCB package that just doesn't have that exact chip, so somebody takes another similar PIC from the library, which looks alike, but does not have the peripherals on the same pins, then not checking..... |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|