|
|
View previous topic :: View next topic |
Author |
Message |
Futterama
Joined: 17 Oct 2005 Posts: 98
|
Problem using MCLR as digital input on PIC18F2320 |
Posted: Thu Oct 29, 2009 7:29 am |
|
|
Hi,
For some reason I cannot use pin1/MCLR/RE3 on PIC18F2320 as digital input. I have set the NOMCLR fuse and defined the port bit. See my code.
I have connected a LED to RA7 for test, and when I toggle the MCLR input voltage level (GND and VDD), nothing happens.
I have read about the MCLR/RE3 input in the datasheet over and over again, and I can't see what I do wrong.
Code: | #include <18F2320.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES NOSTVREN //Stack full/underflow will not cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPB //No Boot Block code protection
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#byte PORTE = 0xF84
#bit RE3 = PORTE.3 // MCLR input pin |
Code: | void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_8MHZ|OSC_INTRC);
TRISA = 0b00000000;
TRISB = 0b00000000;
TRISC = 0b00000000;
while(1)
{
RA7 = RE3;
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 29, 2009 11:07 am |
|
|
The 18F2320 data sheet doesn't show that the MCLR pin can be a normal
digital input pin.
http://ww1.microchip.com/downloads/en/DeviceDoc/39599g.pdf
Look at this table on page 11 (page 13 in the Acrobat reader):
Quote: | TABLE 1-2: PIC18F2220/2320 PINOUT I/O DESCRIPTIONS |
It says that the pin can be either:
Quote: |
Master Clear input (i.e., MCLR reset pin)
or
Programming voltage input (i.e., for ICD2, PicStart-Plus, ICD-U40, etc.) |
Maybe you have an older data sheet. Look at this data sheet errata,
on the upper left side, on page 4:
http://ww1.microchip.com/downloads/en/DeviceDoc/80156f.pdf
It says you can't use RE3 as an input on the 18F2320. |
|
|
Futterama
Joined: 17 Oct 2005 Posts: 98
|
|
Posted: Thu Oct 29, 2009 11:51 am |
|
|
PCM, you are absolutely right, I have an older datasheet on my computer (2003).
Well, I'll have to find another PIC with 24 outputs and MCLR as input - or maybe I'll pick a 40-pin device.
Thanks for your help! I'll go update all my Microchip datasheets now to avoid such problems again.
Thanks again! |
|
|
|
|
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
|