View previous topic :: View next topic |
Author |
Message |
wrainer
Joined: 03 Jul 2012 Posts: 2
|
dsPIC33FJ12MC202 |
Posted: Tue Jul 03, 2012 5:16 pm |
|
|
Hi,
I'm trying to use all I/O pins of the dsPIC33FJ12MC202 as general purpose I/O, but, the PWM pins don't work.
Code: | #byte trisb=0x02C8
#byte portb=0x02CA
#byte odcb=0x02CE
#byte latb=0x02CC
#byte trisa=0x02C0
#byte porta=0x02C2
#byte odca=0x02C6
#byte lata=0x02C4
#byte pwm1con1=0x01C8
#byte p2tcon=0x05C0
void main()
{
trisb=0;
odcb=0;
trisa=0;
odca=0;
setup_spi( FALSE );
setup_wdt(WDT_OFF);
setup_timer1(TMR_DISABLED|TMR_DIV_BY_1);
set_pullup(false);
while(TRUE)
{
latb=0xFFFF;
lata=0xFFFF;
delay_ms(500);
latb=0;
lata=0;
delay_ms(500);
}
} |
Is there some additional configuration missing?
RB0 through RB7 work fine but RB8 through RB15 don't work.
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 03, 2012 6:06 pm |
|
|
I don't have this compiler, but the first thing to do would be to download
the data sheet for the dsPIC33FJ12MC202 and look in the i/o port and PWM sections:
http://ww1.microchip.com/downloads/en/DeviceDoc/70265E.pdf
Look at the PWMxCON1 register description on page 161:
Quote: |
REGISTER 15-5: PWMxCON1: PWM CONTROL REGISTER
|
Look at the default power-on reset settings of certain bits that control
the pin configurations (ie, configured as i/o or PWM). This should give
you a clue as to how to fix it. |
|
|
wrainer
Joined: 03 Jul 2012 Posts: 2
|
|
Posted: Tue Jul 03, 2012 6:39 pm |
|
|
PCM programmer wrote: | I don't have this compiler, but the first thing to do would be to download
the data sheet for the dsPIC33FJ12MC202 and look in the i/o port and PWM sections:
http://ww1.microchip.com/downloads/en/DeviceDoc/70265E.pdf
Look at the PWMxCON1 register description on page 161:
Quote: |
REGISTER 15-5: PWMxCON1: PWM CONTROL REGISTER
|
Look at the default power-on reset settings of certain bits that control
the pin configurations (ie, configured as i/o or PWM). This should give
you a clue as to how to fix it. |
Thanks a lot.
Reading the datasheet I found the FPOR configuration register can bring some troubles. But, I simply solve the problem using output_high and output_low. Now I must find out why. |
|
|
|