Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F690 portB change interrupt???

Status
Not open for further replies.

mr.gone

New Member
I'm using PIC16F690. I'm having problem with RB port/change interrupt. First of all I set RABPU=0 in Bank1 I went to Bank2 and set all 4 high bits in WPUB and IOCB to high by writting FF to addresses 15h & 16h. In Bank0 I set bit 3 of address B(INTCON).

Now I don't see the weak pullup on the pin and even if I use a 10K resistor and temporarily pull the pin up, I still don't get the port chang interrupt to function????
 
I know about GIE. I have been programming on PICs for a while, just not the '690. Yeah, I already have TMR0 running and using the interrupt. I just cant get port B change interrupt to work yet. There is more configuration to it so maybe it's the sequence or something. Well, back at it today. Thanks :)
 
Yes I do, but I reinable it before exiting the ISR like this:

Bcf b,0
xxxx
xxxx
bsf b,3
bsf b,7
retfie

I think the problem is the port configuration. I'm not sure but if I have weak pull-ups enabled, should I see the pin sitting high?

What I'm seeing is the pin is alway low and my push button switch is tied to ground. But like I said, even if I pull the pin high manually I still don't get the interrupt. I have port B configured as all inputs.
 
Last edited:
mr.gone said:
Yes I do, but I reinable it before exiting the ISR
That bit is set when an interrupt occurs. It must be cleared before exiting the ISR, to allow the next interrupt to be catched. I think this is the problem.

mr.gone said:
I'm not sure but if I have weak pull-ups enabled
I would debug the code with external resistors first (with the weak pull-up resistors disabled).
 
Well I appreciate your help but I think you missed something....

Bcf b,0 ;clear RAB change status interrupt FLAG
xxxx
xxxx
bsf b,3 ; re-enable port change interrupt
bsf b,7
retfie


That ain't it.
 
Oh, sorry, I should have read the code more carefully. Actually you don't re-enable the change interrupt flag bit (that is bit 0) as you wrote. The code seems correct to me.
 
Yeah I think you got in a hurry. I think it's something to do with the configuration but for the life of me I don't see it in the manual. I got a web-ticket into Microchip so I will post the answer. Have you done design with the '690? I have a feeling they left something out of the manual or I need to switch banks on one of the configurtion words to something other that what the manual states.
 
I had one 16F690 and used it with a simple program. Now I'm using PIC16F88/628A and PIC12F675. After reading your first post, I started thinking to use both the weak pull-ups and the on-change interrupts as you do. I checked the datasheets of some PICs and they never say that it's not possibile.
 
mr.gone said:
I'm using PIC16F690. I'm having problem with RB port/change interrupt. First of all I set RABPU=0 in Bank1 I went to Bank2 and set all 4 high bits in WPUB and IOCB to high by writting FF to addresses 15h & 16h. In Bank0 I set bit 3 of address B(INTCON).

Now I don't see the weak pullup on the pin and even if I use a 10K resistor and temporarily pull the pin up, I still don't get the port chang interrupt to function????


Yeah, you see there is a bit of configuration to set it up. I just think something in the manual is incorrect. Well, while I'm waiting for then to look over my code I guess I'll write a few simple tests for port B. You can look too if you got time...lol

000 284E GOTO 0x4e
001 3FFF ADDLW 0xff
002 3FFF ADDLW 0xff
003 3FFF ADDLW 0xff
004 00C0 MOVWF 0x40
005 0803 MOVF 0x3, W
006 00C1 MOVWF 0x41
007 190B BTFSC 0xb, 0x2
008 2900 GOTO 0x100
009 180B BTFSC 0xb, 0 ; flag bit port change int.
00A 2820 GOTO 0x20
00B 0000 NOP
00C 0841 MOVF 0x41, W
00D 0083 MOVWF 0x3
00E 0840 MOVF 0x40, W
00F 178B BSF 0xb, 0x7
010 0009 RETFIE

020 1E06 BTFSS 0x6, 0x4 ; begin ISR
021 2910 GOTO 0x110 ; Want to only work if low
022 280C GOTO 0xc

04E 3000 MOVLW 0
04F 00AC MOVWF 0x2c
050 1683 BSF 0x3, 0x5 ;Set up Bank 1
051 1303 BCF 0x3, 0x6
052 1007 BCF 0x7, 0
053 1087 BCF 0x7, 0x1
054 1107 BCF 0x7, 0x2
055 1187 BCF 0x7, 0x3
056 100F BCF 0xf, 0
057 3000 MOVLW 0
058 00A0 MOVWF 0x20
059 1381 BCF 0x1, 0x7
05A 30FF MOVLW 0xff ; Set port B to all inputs
05B 0086 MOVWF 0x6
05C 1703 BSF 0x3, 0x6 ; Set to Bank 2
05D 1283 BCF 0x3, 0x5
05E 0095 MOVWF 0x15 ; Enable Weak Pull-up/B
05F 0096 MOVWF 0x16 ; Enable Int. on chng "B"
060 1303 BCF 0x3, 0x6
061 1683 BSF 0x3, 0x5
062 0000 NOP
063 0000 NOP
064 0000 NOP
065 0000 NOP

:eek: Right here: found it...LOL. I nop'ed out my bcf 1,7 enable RABPU the enable pull ups. OK need to fix this. How stupid....:D


066 1701 BSF 0x1, 0x6
067 1281 BCF 0x1, 0x5
068 1201 BCF 0x1, 0x4
069 1181 BCF 0x1, 0x3
06A 1101 BCF 0x1, 0x2
06B 1081 BCF 0x1, 0x1
06C 1001 BCF 0x1, 0
06D 1283 BCF 0x3, 0x5
06E 130B BCF 0xb, 0x6
06F 168B BSF 0xb, 0x5
070 120B BCF 0xb, 0x4
071 158B BSF 0xb, 0x3
072 178B BSF 0xb, 0x7
073 0000 NOP
074 0000 NOP
075 0000 NOP
076 0000 NOP
077 0000 NOP
078 0000 NOP
079 0000 NOP
07A 1507 BSF 0x7, 0x2
07B 3008 MOVLW 0x8
07C 00AD MOVWF 0x2d
07D 2386 CALL 0x386
07E 0BAD DECFSZ 0x2d, F
07F 287D GOTO 0x7d
080 1107 BCF 0x7, 0x2
081 2386 CALL 0x386
082 2386 CALL 0x386
083 2386 CALL 0x386
084 1487 BSF 0x7, 0x1
085 2380 CALL 0x380
086 2386 CALL 0x386
087 2386 CALL 0x386
088 1507 BSF 0x7, 0x2
089 0000 NOP
08A 2380 CALL 0x380
08B 1107 BCF 0x7, 0x2
08C 2386 CALL 0x386
08D 1487 BSF 0x7, 0x1
08E 2386 CALL 0x386
08F 2386 CALL 0x386
090 2386 CALL 0x386
091 2386 CALL 0x386
092 1487 BSF 0x7, 0x1
093 2386 CALL 0x386
094 2386 CALL 0x386
095 2386 CALL 0x386
096 1507 BSF 0x7, 0x2
097 2380 CALL 0x380
098 0000 NOP
099 0000 NOP
09A 2393 CALL 0x393
09B 23B2 CALL 0x3b2
09C 0000 NOP
09D 0000 NOP
09E 289D GOTO 0x9d

The ISR port RB,4

110 100B BCF 0xb, 0
111 0AAC INCF 0x2c, F
112 0AAC INCF 0x2c, F
113 23B2 CALL 0x3b2
114 100B BCF 0xb, 0
115 2380 CALL 0x380
116 158B BSF 0xb, 0x3
117 280C GOTO 0xc
 
I still can't get it and Microchip closed out the ticket saying it was resolved...lol. Here's my latest configuration.....

050 1683 BSF 0x3, 0x5 ; Go to Bank1
051 1303 BCF 0x3, 0x6
052 1007 BCF 0x7, 0
053 1087 BCF 0x7, 0x1
054 1107 BCF 0x7, 0x2
055 1187 BCF 0x7, 0x3
056 100F BCF 0xf, 0
057 3000 MOVLW 0
058 00A0 MOVWF 0x20
059 1381 BCF 0x1, 0x7
05A 30FF MOVLW 0xff ; Set trisB input
05B 0086 MOVWF 0x6
05C 1703 BSF 0x3, 0x6 ; Goto Bank2
05D 1283 BCF 0x3, 0x5
05E 0095 MOVWF 0x15 ; Turn on WPUB pull ups
05F 0096 MOVWF 0x16 ; Set IOCB interrupt on change
060 3000 MOVLW 0 ; Set ANSEL to digital I/O
061 009E MOVWF 0x1e
062 1303 BCF 0x3, 0x6 ; Goto Bank1
063 1683 BSF 0x3, 0x5
064 0000 NOP
065 1381 BCF 0x1, 0x7 ; RABPU pull ups enabled
066 1701 BSF 0x1, 0x6
067 1281 BCF 0x1, 0x5
068 1201 BCF 0x1, 0x4
069 1181 BCF 0x1, 0x3
06A 1101 BCF 0x1, 0x2
06B 1081 BCF 0x1, 0x1
06C 1001 BCF 0x1, 0
06D 1283 BCF 0x3, 0x5 ; Back to Bank0
06E 130B BCF 0xb, 0x6
06F 168B BSF 0xb, 0x5
070 120B BCF 0xb, 0x4
071 158B BSF 0xb, 0x3 ; Enable port change interrupt
072 178B BSF 0xb, 0x7
 
Last edited:
Have you asked the question in the Microchip forum?

A lot of knowledgable (about PICs) people help in that forum including some Microchip employees.

I don't mean to insult anyone in this forum as there are plenty with excellent PIC knowledge, its just that the Microchip one is dedicated to the subject of PICs and related issues so you will have a different audience.
 
ljcox said:
Have you asked the question in the Microchip forum?

A lot of knowledgable (about PICs) people help in that forum including some Microchip employees.

I don't mean to insult anyone in this forum as there are plenty with excellent PIC knowledge, its just that the Microchip one is dedicated to the subject of PICs and related issues so you will have a different audience.


Yeah, I got one response that was way off...lol
 
Nigel Goodwin said:
But if he's not posting the source code there either, people probably can't be bothered!
I agree, I don't have the time to hunt through the above code.

I expect that I'm not the only one.

Posters should make it as easy for the responder as possible.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top