Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with external interrupt in PIC18F4550

Status
Not open for further replies.

mig29fulcrum

Junior Member level 1
Joined
Sep 29, 2011
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,391
Hi
I wanna use a switch to toggle one pin using external interrupt(INT0) and I'm running a simulation in Proteus,but switch does not work.i found that when i add "bsf INTCON,INT0IF" before"bra $" i have an interrupt and after that nothing happens.
I will appreciate if you help me with this .
TNX...
Code:
		list p=18f4550
	#include p18f4550.inc
	config FOSC=INTOSC_EC
	config WDT=OFF
;===========jump to main=============
	org 0h
	goto main
;===========jump into ISR============
	org 8h	
	goto isr
;============main program============
	org 100h
main
	bcf TRISD,0		;led
	bsf TRISB,INT0	;switch
	bsf INTCON,GIE	;global interrupt enable
	bsf INTCON,INT0IE	;RB0 interrupt enable
	bra $
;===================ISR==============
	org 200h
isr
	btfss INTCON,INT0IF	;ckeck for interrupt
	retfie	;if no then return
	btg LATD,0		;toggle led
	bcf INTCON,INT0IF	;clean interrupt flag
	retfie
	end
 

Hi,

Don't know why you have chosen the 4550 to start Assembler with, its not the easiest of chips to get going on.

The Non USB 2520 or 4520 are much easier to use if you are just simulating.

Whenever starting with a new chip, look in the Microchip Assembler folder for the TEMPLATES files, these lay out the basic program structure for you.

I have taken the 4550 template and added your code to it with a couple of amendments, it runs ok on the attached sim diagram.
Note you have to toggle the switch twice - changes on the rising edge of a pulse.


hth
 

Attachments

  • INT.rar
    28.2 KB · Views: 81
thank u for your answer,but i compiled your code and tested on the circuit like yours but it didn't work :(
 

Hi,

If the code complied ok for you must assume its something wrong with your actual .dsn, can you rar attach it so I can test it.

How are you using it, direct from ISIS or from MPLAB Debugger Proteus ?
 

Direct from ISIS.here is my .DSN file
 

Attachments

  • test.rar
    16.7 KB · Views: 86

Hi,

Just placed those files on my desktop and simply opened the dsn file and pointed it to the .hex file and it runs fine ??

The led will only change states when the switch is moved from low to high, when you move it from high to low nothing will happen -that is correct.

RB0 is set to sense a change on the rising edge of a pulse.

Assume you have Edited the Pic chip to select the correct .hex file ? and a clock speed ?

Have you been able to get any other simulation to work on the 4550, even a simple led flasher ?
 

Attachments

  • ScreenShot002.jpg
    ScreenShot002.jpg
    68.5 KB · Views: 98
  • ScreenShot003.jpg
    ScreenShot003.jpg
    35.8 KB · Views: 93
I hardly found a 18f4550 with an led and tested your code and worked fine :)
THANK U.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top