View previous topic :: View next topic |
Author |
Message |
cyberant
Joined: 04 Jun 2007 Posts: 27
|
RA4/TOCKI readout hangs |
Posted: Mon Jun 18, 2007 4:08 am |
|
|
I have a problem with RA4/TOCKI
I have a switch on RA4 which switches RA4 to high or low. I try`d my programm with the switch on RA3/AN3 und it works without a problem, but as soon as i connect the switch to ra4 und press it my programm stops and i have no reaction on my RS232 imputs anymore.
Do i have to set RA4 in analog mode or something like this?
Ive allready done: "setup_adc_ports(AN0)"
and my programm works with RA3/AN3 - i suggest the problem must be something with the TOCKI function of RA4 - how can I set RA4/TOCKI to work as a normal digital input? (I already try`d the search function...) |
|
|
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Mon Jun 18, 2007 4:23 am |
|
|
Hello,
What device do you use ?
With some pic as 18f252, the RA4 is different than other RA.
Here is the description from Microchip data sheet Quote: | The RA4 pin is multiplexed with the Timer0 module
clock input to become the RA4/T0CKI pin. The RA4/
T0CKI pin is a Schmitt Trigger input and an open drain
output. All other RA port pins have TTL input levels and
full CMOS output drivers. |
Your problem is probably the way you pull up the pin.
As the A4 pin is a Schmitt Trigger input, it need 4V for logic 1.
How did you connected you switch ?
Best regards,
dro. _________________ in médio virtus |
|
|
cyberant
Joined: 04 Jun 2007 Posts: 27
|
|
Posted: Mon Jun 18, 2007 6:05 am |
|
|
My switch works correctly - switches between 0-4V (works without problems in AN3).
I use the PIC 16F877
Looks like I found the problem:
enable_interrupts(GLOBAL);
if i enable global interrupts the problem happens. Without this it works fine. But I didn`t write any interrupt routine - so its strange that it doesn`t jump out of the interrupt - or?? |
|
|
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Mon Jun 18, 2007 8:43 am |
|
|
Hello,
Could-you send the complete configuration ?
dro _________________ in médio virtus |
|
|
cyberant
Joined: 04 Jun 2007 Posts: 27
|
|
Posted: Mon Jun 18, 2007 11:49 am |
|
|
What complete Configuration do u need? I have try`d the switch - works fine on AN3(its no Hardware Problem) but not on AN4 with enable_interrupts(GLOBAL);
I think because it jumps into the interrupt and dont go back into the normal Programm - but Ive not wrote a Interrupt Service Routine or something... |
|
|
Ttelmah Guest
|
|
Posted: Mon Jun 18, 2007 12:54 pm |
|
|
Er.
If you enable interrupts, you _must_ have an interrupt handler (there is no point in enabling interrupts, unless you do have a handler, and without a handler present, with the interrupts enabled, the _hardware_, will jump to the handler, _which is not there..._).
Best Wishes |
|
|
|