Author Topic: Which Interrupt type to use?  (Read 6961 times)

0 Members and 1 Guest are viewing this topic.

Offline tahmodTopic starter

  • Contributor
  • Posts: 31
Which Interrupt type to use?
« on: April 20, 2013, 11:09:57 pm »
I want to interrupt my program when the time of 5 second has passed out during a specific area of my program and tell the program to go somewhere else in my code.
1-Is this the timer0 interupt?
2-If it is timer0 interupt ,then if some one has an example so I can build it in my MPLAB?
3.I have done wrote this interupt from a book, but it did not built how can I solve the errors?

include p16f84a.inc
;PORT A all output
;Port B:bit 0 = interrupt input
   org 00
   goto start

   org 04   ;here if interrupt occurs
   goto Int_Routine

   org 0010
;Initialise
start bsf status,rp0    ;select bank 1
   movlw 01
   movwf trisb   ;portb bits 1-7 output
            ;   bit 0 is input
   movlw 00
   movwf trisa   ;porta bits all output
;Comment in or out following instruction to change
;Interrupt edge
   bcf option_reg,intedg
   bcf status, rp0 ;select bank 0
   bsf intcon, inte ;enable external interrupt
   bsf intcon,gie ;enable global int

wait movlw 0a   ;set up initial port output values
   movwf porta
   nop
   movlw 15
   movwf porta
   goto wait

   org 0080
Int_Routine
   movlw 00
   movwf porta
   bcf intcon, intf ;clear the interrupt flag
   end

Error:
1 : Found directive in column 1. (include) 
12 : Symbol not previously defined (status) 
12 : Symbol not previously defined (rp0)
 14 : Symbol not previously defined (trisb)
 17 : Symbol not previously defined (trisa) 
20 : Symbol not previously defined (intedg) 
21 : Symbol not previously defined (status) 
21 : Symbol not previously defined (rp0) 
22 : Symbol not previously defined (intcon)
 22 : Symbol not previously defined (inte) 
23 : Symbol not previously defined (intcon) 
23 : Symbol not previously defined (gie) 
26 : Symbol not previously defined (porta) 
29 : Symbol not previously defined (porta)
 35 : Symbol not previously defined (porta)
 36 : Symbol not previously defined (intcon) 
36 : Symbol not previously defined (intf)
Halting build on first failure as requested.
« Last Edit: April 20, 2013, 11:12:01 pm by tahmod »
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4720
  • Country: au
  • Question Everything... Except This Statement
Re: Which Interrupt type to use?
« Reply #1 on: April 20, 2013, 11:12:35 pm »
if you set up the timer correctly, right when you want to start measuring from, you could get the timer to overflow close to your desired 5 seconds, and use that interrupt
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2187
  • Country: au
Re: Which Interrupt type to use?
« Reply #2 on: April 20, 2013, 11:33:47 pm »
...how can I solve the errors?

include p16f84a.inc
...
Error:
1 : Found directive in column 1. (include) 
...
Needs to be "#include"

p16f84a.inc should have all the definitions for the "symbols not defined" errors
 

Offline mikes

  • Regular Contributor
  • *
  • Posts: 188
  • Country: us
Re: Which Interrupt type to use?
« Reply #3 on: April 20, 2013, 11:35:44 pm »
how can I solve the errors?

include p16f84a.inc
;PORT A all output
...
Error:
1 : Found directive in column 1. (include) 
12 : Symbol not previously defined (status)
The error tells you - don't start an include directive in the first column. Put a space in front of it. Fixing that looks like it will fix the rest of the errors - which are because the .inc wasn't loaded, and it contains the definitions.
 

Offline tahmodTopic starter

  • Contributor
  • Posts: 31
Re: Which Interrupt type to use?
« Reply #4 on: April 20, 2013, 11:39:27 pm »
-Rerouter, do you have any example of similar code ?


-I wrote this code it still not working. There is all the other error left.
   #include p16f84a.inc
;PORT A all output
;Port B:bit 0 = interrupt input
   org 00
   goto start

   org 04   ;here if interrupt occurs
   goto Int_Routine

   org 0010
;Initialise
start bsf status,rp0    ;select bank 1
   movlw 01
   movwf trisb   ;portb bits 1-7 output
            ;   bit 0 is input
   movlw 00
   movwf trisa   ;porta bits all output
;Comment in or out following instruction to change
;Interrupt edge
   bcf option_reg,intedg
   bcf status, rp0 ;select bank 0
   bsf intcon, inte ;enable external interrupt
   bsf intcon,gie ;enable global int

wait movlw 0a   ;set up initial port output values
   movwf porta
   nop
   movlw 15
   movwf porta
   goto wait

   org 0080
Int_Routine
   movlw 00
   movwf porta
   bcf intcon, intf ;clear the interrupt flag
   end


how can I solve the errors?

include p16f84a.inc
;PORT A all output
...
Error:
1 : Found directive in column 1. (include) 
12 : Symbol not previously defined (status)
The error tells you - don't start an include directive in the first column. Put a space in front of it. Fixing that looks like it will fix the rest of the errors - which are because the .inc wasn't loaded, and it contains the definitions.
« Last Edit: April 20, 2013, 11:41:15 pm by tahmod »
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5360
  • Country: ro
  • .
Re: Which Interrupt type to use?
« Reply #5 on: April 20, 2013, 11:46:30 pm »
How about you stop pasting code from books and come back to us when you actually bother to read the PIC datasheet and the explanation for those instructions ?

It's obvious you don't read the datasheets, you don't understand the instructions, you just want to copy and paste.

If you don't care about instructions, write the code in C in MPLAB and the C compiler will hide the exact instructions from you... but you still HAVE TO read at least the datasheet.


 

Offline tahmodTopic starter

  • Contributor
  • Posts: 31
Re: Which Interrupt type to use?
« Reply #6 on: April 20, 2013, 11:52:54 pm »
What is the problem? I am reading a book I just wanted to test it in the computer and it built with error. There is nothing to do with the datasheet.
How about you stop pasting code from books and come back to us when you actually bother to read the PIC datasheet and the explanation for those instructions ?

It's obvious you don't read the datasheets, you don't understand the instructions, you just want to copy and paste.

If you don't care about instructions, write the code in C in MPLAB and the C compiler will hide the exact instructions from you... but you still HAVE TO read at least the datasheet.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Which Interrupt type to use?
« Reply #7 on: April 21, 2013, 12:16:23 am »
What is the problem? I am reading a book I just wanted to test it in the computer and it built with error. There is nothing to do with the datasheet.

 ??? The datasheet tells you how it works! It has everything to do with the datasheet. The answer to every one of your interrupt-related questions is in there. You did say it wouldn't build, but that was only one question.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5360
  • Country: ro
  • .
Re: Which Interrupt type to use?
« Reply #8 on: April 21, 2013, 12:29:39 am »
What is the problem? I am reading a book I just wanted to test it in the computer and it built with error. There is nothing to do with the datasheet.


What you're doing is like trying to learn a language without knowing the grammar rules and the letters. You can't just copy phrases from a book.

The assembly language has particularities and the assembly language manual tells you what some assembly language specific keywords mean, how the compiler converts what you type into microcontroller code and all that.
Had you read the assembly language manual, you would have learned what those error messages ": Symbol not previously defined" are telling you that the assembler has no idea what those keywords mean because you forgot to tell the assembler where you defined those keywords.
Each of those keywords have some values associated with them, and those values can differ from microcontroller to another so each mcu has it's own file with those definitions, usually a .inc file.

If your programming IDE or assembler software doesn't have such a file, you can MAKE one using the definitions in your microcontroller's DATASHEET, they're all there, explained.

The same datasheet tells you what all those instructions do IN DETAIL, so if you'd bother to read the datasheet, you'd know why an instruction isn't executed, is skipped, whatever... how can i put it more plainly than this?

The code you keep trying to run is probably relying on snippets of code from previous chapters or examples. and the book assumes you have some basic assembly knowledge and that by the time you're doing this example, you know to have a base program and just add that code to your base program, what you pasted is not a full 100% program.

later edit:  and the "-Is this the timer0 interupt?" is a stupid question ... timer0 isn't an interrupt... it's a stupid timer, your mcu may have one or more timers and it's up to you how to enable them and configure to optionally do an interrupt when time expires. The DATASHEET has a whole chapter about timers WITH examples, read the f**king datasheets and understand the code, don't just paste from books.
« Last Edit: April 21, 2013, 12:35:02 am by mariush »
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Which Interrupt type to use?
« Reply #9 on: April 21, 2013, 12:34:15 am »
Ya...I give up too.
Apparently the word "datasheet" is not in the vocabulary.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5360
  • Country: ro
  • .
Re: Which Interrupt type to use?
« Reply #10 on: April 21, 2013, 12:51:44 am »
Here's what you need to understand, if you don't read these we can't help you here:

MPASM_&_MPLINK_User_Guide :  http://savedonthe.net/download/482/MPASM_-_MPLINK_User_Guide_33014k.html

The first 4 chapters explain how Assembler language words, what the keywords mean, how to write assembler programs.  From the 5th chapter you already have examples of programs explained line by line. But you can't just jump to a random example and paste it and think it would work.

Read the manual, it's important.

Pickit3 Lessons: http://savedonthe.net/download/483/PICkit_3_Lessons_UG_41370c.html

Lessons source code: http://savedonthe.net/download/484/PICkit-3-Debug-Express-Lessons.html

This is a PDF with source code explained, but it's for PIC18 chips that come with the Pickit3 programmer (if you get it with the development board).  PIC18 chips are similar to PIC16 chips, so if you COMPARE the datasheets of your PIC16 chip with the datasheet of the PIC18 chip presented in those lessons, you can adjust the source code to work.
The lessons are in C , which is much, much easier to understand.

Without reading at least the Assembler manual and the datasheet for your own PIC chip, you have little chance of understanding how the programs you keep copying from books. Do yourself a favor and read them.
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Which Interrupt type to use?
« Reply #11 on: April 21, 2013, 04:22:33 am »
Maybe the homework is due next week?   :-DD
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline tahmodTopic starter

  • Contributor
  • Posts: 31
Re: Which Interrupt type to use?
« Reply #12 on: April 21, 2013, 09:03:11 am »
-Thanks mariush I am planning to read the Pickit3 Lessons, Lessons source code and the MPASM guide. The Pickit 3 has some good example of project.
-I look at the datasheet for the "Symbol not previously defined", you need to define it with equ but when I assemble it give me "Argument out of range.  Least significant bits used.".

I define all the key words
status    equ 03
porta   equ 05   
trisa    equ 05   
portb   equ 06   
trisb    equ 06   
trisd    equ 08
latd   equ 11
intcon    equ 0b

rp0      equ 16
option_reg equ 17
intedg   equ 18
rp0   equ 19
inte   equ 20
gie      equ 21
intf   equ 22
loop1 equ 12
loop2 equ 13
loop3 equ 14
tisr equ 15

Here's what you need to understand, if you don't read these we can't help you here:

MPASM_&_MPLINK_User_Guide :  http://savedonthe.net/download/482/MPASM_-_MPLINK_User_Guide_33014k.html

The first 4 chapters explain how Assembler language words, what the keywords mean, how to write assembler programs.  From the 5th chapter you already have examples of programs explained line by line. But you can't just jump to a random example and paste it and think it would work.

Read the manual, it's important.

Pickit3 Lessons: http://savedonthe.net/download/483/PICkit_3_Lessons_UG_41370c.html

Lessons source code: http://savedonthe.net/download/484/PICkit-3-Debug-Express-Lessons.html

This is a PDF with source code explained, but it's for PIC18 chips that come with the Pickit3 programmer (if you get it with the development board).  PIC18 chips are similar to PIC16 chips, so if you COMPARE the datasheets of your PIC16 chip with the datasheet of the PIC18 chip presented in those lessons, you can adjust the source code to work.
The lessons are in C , which is much, much easier to understand.

Without reading at least the Assembler manual and the datasheet for your own PIC chip, you have little chance of understanding how the programs you keep copying from books. Do yourself a favor and read them.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5360
  • Country: ro
  • .
Re: Which Interrupt type to use?
« Reply #13 on: April 21, 2013, 12:04:14 pm »
Quote
I am planning to read the Pickit3 Lessons, Lessons source code and the MPASM guide.

DO THAT first. Don't expect to get answers before you do that, because even if we give them to you, you won't understand why you have to do it like we say. The MPASM guide tells you that.

You can keep asking questions and wasting days of your time and not remaining with anything in your head after getting answers, or you can start reading and trying to understand for a few hours and find your own answers. There's no magic solution.

If you find the Pickit3 lessons more accessible, just drop the assembler language altogether and start doing C. The C compiler comes with headers for various PIC chips, just like the asm compiler should come with include files for chips.
But for C, the pic chip datasheet is like a manual, it explains everything you need to know.  You need the datasheet anyway for the definitions for assembler.
« Last Edit: April 21, 2013, 12:05:48 pm by mariush »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->