is it because pic sets all ports to input pins upon powerup?
Hi xnihilo,
skimask has pinpointed the passage in the datasheet that clearly tells you what you need to do before enabling the interrupt and after servicing the interrupt. I appreciate that English is probably not your first language but re-examine the paragraph and what it tells you is required before enabling the interrupt?
Regards,
Bob
Please, no more riddles.
I beleive the portA has to be read prior to enabling interrupts.
Are these steps order right?
- enable weak pullups with OPTION_REG = %01111111 (even if I DON'T know what should be the settings for bits 0 to 6, which seem not useful for me)
- enable WPU for desired ports, for me it should be: 010111 (no WPU for RA3 which is used as an input port) (no WPU for RA5 which is used with default 0V and is activated when 5V gets to this pin)
- TRISA = %101111 because all porta pins has to be input except for pin RA4 which is used for R/S bit for an LCD pannel
- TRISC = %000000 (all output)
- PORTA.5 = 0 (I set specificaly RA5 to 0 because I want it to be LOW at the start, all other porta pins will be brought high automatically by WPU)
- PORTC = %000000 (I set all portC pins low)
- I initialize all my variables
- I put some stuff here like display on LCD
- IOCA = %101111 because I enable PORTA change interrupt for all porta pins except for the pin used for LCD R/S bit
- INTCON = %10001000 (I enable interrupts: GIE and portachange)
- ON INTERRUPT GOTO myroutine
Is that correct?
Last edited by skimask; - 21st March 2008 at 00:44.
Re-Read the replys the Clue to solve your mystery is "I.O.C."...
hopes this helps just a little
Bookmarks