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.

Interrupts

Status
Not open for further replies.
I am looking to flash an LED on RA1 by using the Timer1 interrupt.
As you can see in my program the main processor is running on the internal clock at 8Mhz.
I have connected a 32.768KHz crystal and used 33pf capacitors like in the data book across TIOSCI (Pin 13) and TIOSCO (Pin12).
The oscillator appears to run, albeit the signal is low and sinusioidal but the program dosen't seem to do anything else.
Any help would be very much appreciated.

I have attached my linker file too as I originally had the interrupt vector in the wrong place.
It seems that you have to pad out some bytes after the reset goto statement. Is there a way of changing the linker to force things into the correct positions without padding ?

Many thanks Mark.
 

Attachments

  • attached1.zip
    6.1 KB · Views: 142
Last edited:
You have not set the Global Interrupt Enable and the Peripheral Interrupt Enable bits.
You need to add the following code,
Code:
		movlw	0xc0
		movwf	INTCON

You also are not saving anything in your ISR. It won't matter for this program as your main code isn't doing anything but will cause you a headache later. Your code that you originally posted had the context saving code.

HTH

Mike.
Edit, your interupt code doesn't make sense either. It stores W in temp1 and never gets to the line "bcf temp1,2"
 
Last edited:
You need to go back to the data sheet and practice reading it carefully. If you don't understand what it is saying or what the picture, or the table is all about the ask the specific question. Way too many posters form an idea, sling some code, and find themselves at sea when things don't work. The information that you require is right in front of you if only you would have the patience and the discipline to spend a few minutes making sure that you understand what is going on.
 
Papabravo said:
You need to go back to the data sheet and practice reading it carefully. If you don't understand what it is saying or what the picture, or the table is all about the ask the specific question. Way too many posters form an idea, sling some code, and find themselves at sea when things don't work. The information that you require is right in front of you if only you would have the patience and the discipline to spend a few minutes making sure that you understand what is going on.

I think you are being a little bit harsh. If you look at the code that he has posted, it is well written and well documented. He has obviously read and understood the data sheet. The mistake he has made is understandable given the fact he is just learning.

Mike.
 
Harsh in what sense? It was an accurate statement based on a key feature of an interrupt system which is enabling and disabling it. It also did not help that the ususal code for saving the state of the machine was omitted. This code is encased in a prominent box in every PIC data sheet. To ignore both of these things seems a bit hurried and rushed. I'm just suggesting that better results may be achieved faster by taking some time and some care.

I understand that many people who frequent these forums are inexperienced and eager to learn. In no way were my comments meant to denigrate the effort expended. A correctly working program is actually a fairly high bar get over. The way you get over that bar is to do exactly what I suggested. I feel that the advice I gave was valuable and appropriate in the circumstances.

My advice might be an artifact of the 24 hour turnaround for program changes that was typical when I learned my craft. Today it has been reduced to mere seconds!
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top