View previous topic :: View next topic |
Author |
Message |
potato
Joined: 23 Mar 2014 Posts: 16
|
[solved] crazy about pin RA4 in PIC18F4550 |
Posted: Sat May 17, 2014 8:59 am |
|
|
Hi again!
I've been doing some research here on the forum and I think I'll soon become crazy... My PIC ignores the inputs coming from pin A4 (I have a button there and there are no bouncing problems).
I thought I saw some light when I came across a couple of threads talking about #fuses NOIESO and #fuses SOSC_DIG or DIGITAL... but my compiler (version 4.0, though I've tried it with version 4.1 and it doesn't work, either) doesn't recognise the second fuse, neither SOSC_DIG or SOSC_DIGITAL.
I have to use this pin because the others are occupied (or not working, as A5, C1, C4, C5 or B7). It's not a PIC's problem, because I bought a new one and it's just the same...
What can I do? The fuses are the following:
Code: | #include <18F4550.h>
#FUSES HS //4 Mhz clock
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOWDT //No Watch Dog Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOLVP //No Low Voltage Programming on B5(PIC18)
#FUSES CPUDIV1 //No System Clock Postscaler
#FUSES NOPBADEN //PORTB pins are NOT configured as analog input channels on RESET
#fuses NOIESO //Internal External Switch Over mode disabled
#fuses SOSC_DIG //To use the SOSC pins as normal i/o
#use delay(clock=4000000)
|
Many thanks!
Last edited by potato on Sat May 17, 2014 9:51 am; edited 1 time in total |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat May 17, 2014 9:29 am |
|
|
Some questions:
1) Does your hardware successfully passed the basic test of a blinking LED?
2) If so, did you check if the LED blinking period corresponds with the code?
3) How is connected the button in A4?
5) Did you add a 10k pull-up resistor with the button?
6) Are you aware of this fuse set?
Quote: | #fuses SOSC_DIG //To use the SOSC pins as normal i/o |
Regarding the posted info, it is very poor. We need a compilable code.
Nobody could help you if you only post the fuses configuration.
regards, _________________ Humber |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
|
Posted: Sat May 17, 2014 9:30 am |
|
|
In addition to what Huberto said....
Since we cant see the rest of your code we have to guess.
Did you disable ADC?
Did you disable CCP? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Sat May 17, 2014 9:37 am |
|
|
That fuse is for PIC's like the PIC24's. Your chip doesn't have it.
Read the data sheet:
"The RA4 pin is multiplexed with the Timer0 module
clock input to become the RA4/T0CKI pin. The RA6 pin
is multiplexed with the main oscillator pin; it is enabled
as an oscillator or I/O pin by the selection of the main
oscillator in Configuration Register 1H (see
Section 25.1 “Configuration Bits” for details). When
not used as a port pin, RA6 and its associated TRIS
and LAT bits are read as ‘0’.
RA4 is also multiplexed with the USB module; it serves
as a receiver input from an external USB transceiver.
For details on configuration of the USB module, see
Section 17.2 “USB Status and Control”.
The command to disable the T0CKI use, is:
setup_timer_0(T0_INTERNAL);
If you are running, you need to be running with the internal transceiver, otherwise the hardware uses this pin. |
|
|
potato
Joined: 23 Mar 2014 Posts: 16
|
|
Posted: Sat May 17, 2014 9:51 am |
|
|
hi guys, thanks for you super-fast replies!
I'm afraid I had no reasons to turn crazy... I've realised I had a software problem, because I had a while loop to wait for a button to be pressed and I didn't write that it also had to wait for a4... (because I had it in another while loop)
I know how stupid it sounds, specially because I had review the code millions of times
Anyway, thanks for the ideas and, Ttelmah, thanks for specialising that I don't have to worry about that pin! |
|
|
|