This is a multi-part message in MIME format. ------=_NextPart_000_02B9_01C90A84.83B57D40 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Harry, I have included the code as I have modified it. Within the source listing, I have highlighted the additions I made so you can see them easily. Put this into your part and see if it works. I have a feeling it will. Let me know if you have any further questions. When you save the attachment, you can rename it to whatever you want to with the extension of ".asm". I renamed it to ".txt" because my Solidworks program thinks it is a Solidworks assembly drawing. Regards, Jim P.S. What are all the numbers in the first column for in the code below? ----- Original Message ----- From: "Harry H. Arends" To: "'Microcontroller discussion list - Public.'" Sent: Saturday, August 30, 2008 9:04 AM Subject: RE: [PIC] No reaction using chanhe on interrupt > OK i added some more code but still the same result. > > ; --- Interrupt routine > ------------------------------------------------------ > org 0x004 > Interrupt: > movwf INT_W ; Save content register > 1 > swapf STATUS, W ; > 2 > movwf INT_STAT ; > 3 > clrf STATUS ; Interrupt uses BANK0 > 4 > > btfsc DCCIN ; DCC signal present > 5 > goto Int_High_Half ; 6 > 7 > Int_Low_Half: > bsf PORTA, 0 > movlw d'256'- d'154' ; 77us timer > 7 > movwf TMR0 ; > 8 > bcf INTCON, T0IF ; Clear IF for counting > 9 > bcf INTCON, RABIF ; Clear IF for IOC PORTA/PORTB > 10 > goto EndInt ; 13 > 14 > Int_High_Half: > bsf PORTA, 1 > nop > End_High_Half: > bcf INTCON, RABIF ; 46 > 31 > EndInt: > swapf INT_STAT, W ; Restore content registers 49 > 34 > movwf STATUS ; 50 > 35 > swapf INT_W, f ; 51 > 36 > swapf INT_W, w ; 52 > 37 > retfie ; 53 54 38 > 39 > > Niether PORT becomes high > > Harry > > -----Oorspronkelijk bericht----- > Van: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] Namens > Matthew > Miller > Verzonden: zaterdag 30 augustus 2008 15:23 > Aan: Microcontroller discussion list - Public. > Onderwerp: Re: [PIC] No reaction using chanhe on interrupt > > On Sat, Aug 30, 2008 at 09:30:12AM +0200, Harry H. Arends wrote: >> >> In witch part of the code should i clear the INTCON, 0 bit? > > You want to clear the interrupt flag (INTCON, 0) in the interrupt service > routine. Basically, once the program has done what should be done for an > interrupt then the next thing the program should do is clear the > appropriate > interrupt flag bit. > > Matthew > -- > http://www.piclist.com PIC/SX FAQ & list archive View/change your > membership > options at http://mailman.mit.edu/mailman/listinfo/piclist > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > ------=_NextPart_000_02B9_01C90A84.83B57D40 Content-Type: text/plain; format=flowed; name="Harry Test.txt"; reply-type=original Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Harry Test.txt" ; errorlevel -302, -305 ; Suppress Bank Warnings list p=3D16F685, r=3Dhex INCLUDE "P16F685.INC" __CONFIG 0x3CE2 ; --- Definetions section ;---------------------------------------------------- ; --- Macros definitions ; --- Constant values #define DCCIN PORTB, 7 ; DCC signal input =20 ; --- Variables in RAM cblock 0x070 ; On bottom of all banks INT_W ; Interrupt context registers INT_STAT ; EEDATA0 ; EEPROM shadow variables endc =20 ; --- Program section ;-------------------------------------------------------- org 0x000 PowerUp: clrf STATUS ; Bank0 is default clrf INTCON ; Disable all interrupts at first clrf PCLATH ; All tables on Bank0 ; Following the datasheet the above could ; onmitted but we use it to be sure goto Init ; --- Interrupt routine ;------------------------------------------------------ org 0x004 Interrupt: movwf INT_W ; Save content register swapf STATUS, W ; movwf INT_STAT ; clrf STATUS ; Interrupt uses BANK0 =20 btfsc DCCIN ; DCC signal present nop nop =20 bsf PORTA, 0 nop=20 bsf PORTA, 1 nop =20 EndInt: swapf INT_STAT, W ; Restore content registers =20 movwf STATUS ; =20 swapf INT_W, f ; =20 swapf INT_W, w ; =20 movwf INTCON nop ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + ; ; This clears the PORTB change=20 ; interrupt flag so that you'll be=20 ; ready for the next PORTB change ; interrupt. bcf INTCON,0 =20 ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + clrf PORTA =20 retfie ; =20 ; --- Set used registers in correct setting ;---------------------------------- Init: ; These registers are in BANK0 clrf PORTA clrf PORTB clrf PORTC =20 BANKSEL TRISA ; These registers are in BANK1 clrf TRISA ; Set to all outputs movlw b'10110000' ; Set RB7, RB5 and RB4 to Input movwf TRISB clrf TRISC ; Set to all outputs movlw b'10001000' ; Set Optionregister to no PullUps, ; no prescaller and WDT 1:1 movwf OPTION_REG clrf WPUA ; Dont use WeakPullUp on PORTA ; We dont use IOC on PORTA so leave = it as it is =20 BANKSEL ANSEL ; These registers are in BANK2 clrf ANSEL ; Set to all digital I/O clrf ANSELH clrf WPUB ; Dont use WeakPullUps on PORTB movlw b'10000000' ; Set RB7 to InterruptOnChange PORTB movwf WPUB =20 =09 ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + ;=20 ; This bit of code sets up the IOCB=20 ; register ; to be able to recognize=20 ; a PORTB change interrupt. BANKSEL IOCB movlw 0x80 movwf IOCB ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + ;+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_= + BANKSEL 0x00 ; Return to BANK0 movlw b'00110001' ; Set Timer1 on at 1:8 movwf T1CON movlw b'10001000' ; Enable all unmasked interrupts and movwf INTCON ; enable PORTA/PORTB interrupt on = change =20 nop bsf PORTC, 2 nop goto $ end ------=_NextPart_000_02B9_01C90A84.83B57D40 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist ------=_NextPart_000_02B9_01C90A84.83B57D40--