PDA

View Full Version : int0.c 8031 nmiy0031


kewl_cat
07-11-08, 11:09 AM
I compiled and assembled int0.c with the following

; MEMORY MAP FOR U3 RAM DEVELOPMENT =====================================
.EQU RAM,H'8F00 ; starting address of data RAM, NEVER 0!
.EQU STACKTOP,H'8FFE ; initial stack pointer, MUST BE EVEN!
.EQU ROM,H'8000 ; starting address of program on U3 is 8000h
.EQU LITROM,H'8C00 ; literals address

I execute X 8000 in Monitor and it responds to pull int0 low...

How do I trigger an external interrupt? I connected int0 to GND on the pinout on the board and nothing happens.

thanks

RMDumse
07-11-08, 02:13 PM
Interrupts are usually of two types, maskable and non-maskable. Non-maskable interrupts cannot be ignored. Maskable ones can be, and must be set up before they are taken. I think that is the case with T0.

You will need an interrupt vector set up, then enable interrupts, and this is often in two places, one for the pin, and another in general before the processor will take an interrupt.

Without the interrupt vector being set up, if you were successful with T0 inducing an interrupt, a crash/lockup of your program would have been the likely outcome.

A study of the 8051 processor's manual should supply your answers.

A Google search turns up lots of articles and written resources on 8031 interrupts.

http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLJ,GGLJ:2006-37,GGLJ:en&q=8031+interrupt+T0

kewl_cat
07-11-08, 07:16 PM
Can you write a interrupt in Smallc? All the examples I have seen on the site are in assembler. I saw examples with other C compilers but not smallc. Something like timer_0() interrupt 1 using 2....

RMDumse
07-11-08, 08:01 PM
Sure you can. There's lots of responsibilities on the programmer, setting up enables, and dealing with clearing the interrupt condition before leaving, but it certainly can be done.

RMDumse
07-11-08, 08:08 PM
Have a look at previously posted references. I think this, specifically on the 8031 timer, has been covered before.

http://www.newmicros.com/discussion/showthread.php?t=644

and

http://www.newmicros.com/discussion/archive/index.php/t-437.html