Hi DT,
When @ INT_DISABLE TMR0_INT command is used @4Mhz 16F628A, can you estimate how long does it take to process it and eventually disable it?
uS?
Thanks.
Hi DT,
When @ INT_DISABLE TMR0_INT command is used @4Mhz 16F628A, can you estimate how long does it take to process it and eventually disable it?
uS?
Thanks.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Hi Sayzer,
For 14-bit chips,
It takes 1 instruction cycle to disable the interrupt and depending on what bank it's in at the time, it may take 1 or 2 instructions to change to the correct bank before disabling.
So @ 4mhz, it could take from 1 to 3 uS.
On 18F's, it's always just 1 instruction.
<br>
DT
Not sure if this have been covered, but however. I'm actually working with a PIC16F616, there's no interrupt on PORTB change on this one, but Interrupt on PORTA change, great Microchip
From what i see, it is not included in DT_INTS-14, so here's one method to do so...
Open DT_INTS-14, and add the sections in Red
Sure enough there's some other PIC with interrupt on PORTA change, I just never came across one... or maybe... but never used that feature yetCode:ASM #define INT_INT INTCON,INTF ;-- INT External Interrupt #define RBC_INT INTCON,RBIF ;-- RB Port Change Interrupt #define RAC_INT INTCON,RAIF ;-- RA Port Change Interrupt #define TMR0_INT INTCON,T0IF ;-- TMR0 Overflow Interrupt 16F #define TMR1_INT PIR1,TMR1IF ;-- TMR1 Overflow Interrupt #define TMR2_INT PIR1,TMR2IF ;-- TMR2 to PR2 Match Interrupt #define TX_INT PIR1,TXIF ;-- USART Transmit Interrupt #define RX_INT PIR1,RCIF ;-- USART Receive Interrupt #define CMP_INT PIR2,CMIF ;-- Comparator Interrupt #define EE_INT PIR2,EEIF ;-- EEPROM/FLASH Write Operation Interrupt #define BUS_INT PIR2,BCLIF ;-- Bus Collision Interrupt #define PSP_INT PIR1,PSPIF ;-- Parallel Slave Port Read/Write Interrupt #define AD_INT PIR1,ADIF ;-- A/D Converter Interrupt #define SSP_INT PIR1,SSPIF ;-- Master Synchronous Serial Port Interrupt #define CCP1_INT PIR1,CCP1IF ;-- CCP1 Interrupt #define CCP2_INT PIR2,CCP2IF ;-- CCP2 Interrupt ENDASM asm INT_Source macro IFR, IFB, IER, IEB if ((IflagReg == IFR) && (IflagBit == IFB)) list INT_Flag_Reg = IFR INT_Flag_Bit = IFB INT_Enable_Reg = IER INT_Enable_Bit = IEB Found = YES endif ; nolist endm endasm asm ;------------------------------------------------------------------------------- GetIntInfo macro IflagReg, IflagBit Found = NO ; nolist ifdef INTF ;----{ INT External Interrupt }----------------[INTCON, INTF]--- INT_Source INTCON, INTF, INTCON, INTE endif ifdef RBIF ;----{ RB Port Change Interrupt }--------------[INTCON, RBIF]--- INT_Source INTCON, RBIF, INTCON, RBIE endif ifdef RAIF ;----{ RA Port Change Interrupt }--------------[INTCON, RAIF]--- INT_Source INTCON, RAIF, INTCON, RAIE endif ifdef T0IF ;----{ TMR0 Overflow Interrupt }-------------[INTCON, TMR0IF]--- INT_Source INTCON, T0IF, INTCON, T0IE endif ifdef TMR1IF ;----{ TMR1 Overflow Interrupt }---------------[PIR1, TMR1IF]--- INT_Source PIR1, TMR1IF, PIE1, TMR1IE endif ifdef TMR2IF ;----{ TMR2 to PR2 Match Interrupt }-----------[PIR1, TMR2IF]--- INT_Source PIR1, TMR2IF, PIE1, TMR2IE endif ifdef TXIF ;----{ USART Transmit Interrupt }----------------[PIR1, TXIF]--- INT_Source PIR1, TXIF, PIE1, TXIE endif ifdef RCIF ;----{ USART Receive Interrupt }------------------[PIR1 RCIF]--- INT_Source PIR1, RCIF, PIE1, RCIE endif ifdef CMIF ;----{ Comparator Interrupt }--------------------[PIR2, CMIF]--- ifdef PIR2 INT_Source PIR2, CMIF, PIE2, CMIE else INT_Source PIR1, CMIF, PIE1, CMIE endif endif ifdef EEIF ;---{ EEPROM/FLASH Write Operation Interrupt }---[PIR2, EEIF]--- ifdef PIR2 INT_Source PIR2, EEIF, PIE2, EEIE else INT_Source PIR1, EEIF, PIE1, EEIE endif endif ifdef BCLIF ;----{ Bus Collision Interrupt }----------------[PIR2, BCLIF]--- INT_Source PIR2, BCLIF, PIE2, BCLIE endif ifdef PSPIF ;--{ Parallel Slave Port Read/Write Interrupt }--[PIR1, PSPIF]-- INT_Source PIR1, PSPIF, PIE1, PSPIE endif ifdef ADIF ;----{ A/D Converter Interrupt }------------------[PIR1, ADIF]--- INT_Source PIR1, ADIF, PIE1, ADIE endif ifdef SSPIF ;----{ Master Synchronous Serial Port Interrupt }--[PIR1, SSPIF]- INT_Source PIR1, SSPIF, PIE1, SSPIE endif ifdef CCP1IF ;----{ CCP1 Interrupt }-------------------------[PIR1, CCP1IF]--- INT_Source PIR1, CCP1IF, PIE1, CCP1IE endif ifdef CCP2IF ;----{ CCP2 Interrupt Flag }--------------------[PIR2, CCP2IF]--- INT_Source PIR2, CCP2IF, PIE2, CCP2IE endif list endm list ENDASM![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Oops - double post....removed.
Last edited by HankMcSpank; - 19th May 2009 at 14:25.
mister_e.... I'd like to get interupts working on my 16F690 ....I visited Darrel's website & on the very first example "Hello World", he shows the code along with a short schematic - the interupt is showing as being presented on port RBO (actually called RBO/INT on the diagram).
I have some (newbie!) questions...
Are Darrel's interput routines for a specific PIC?
I ask because my PIC 16F690 doesn't even have an RB0(!), therefore to my next question....
Is there a particular PIC pin I should be using for his routines to work.
My end goal is quite simple...I have an encoder wheel with 48 black stripes that I'm having one helluva job getting the polling right....I'd simply like to be able to use a PIC interupt for when each black stripe passes the photo transistor 'pickup' (to increment a PIC counter)
That said, for testing puproses I do need one more interupt ...this being for a magnetic switch (I've glued a magnet to the edge of the disc so I know when the wheel has turned once) to interupt once per rev, I can then make sure that the PIC 'saw' all the stripes for the past rev....so to my other question - is there normally just one INT pin that's useable for externally triggered interupts on a PIC (specifically a 16F690)
i'd dearly love to be able to use Darrel's simple routines...but I'm a little clueless wrt ensuring I'm connecting my incoming 'pulses' to the correct PIC 16F690 pins!
edit: Darrel has kindly replied to the earlier PM I sent him, telling me that I need to look for the pin marked 'INT'...which on my PIC 16F690 is apparently pin RA2 - tks Darrel!
Last edited by HankMcSpank; - 19th May 2009 at 14:24.
Hi,
If you have a T?CKI pin on your pic you can use that pin to check for black stripes. This is the pin for the external clock signal connected to the internal timer/counter. This way you can get an interupt every black stripe or every 2:nd or once per wheel rotation (or anything else more or less). This is all depending of what you preload the counter with. If you have a 8-bit counter and load FF into it, next clock pulse will overflow the counter and you will get an interupt. If you preload it with FF-(dec 48) it will overflow once every full rotation of the wheel.
If you just want to count the stripes preload it with 0 and off you go....
This way your PIC will do most of the counting by itself and giving you more instruction time for something more useful.
If you use the RA2/INT for the magnetic switch you can use RA5/T1CKI the external clock input for the stripes phototransistor
/me
Last edited by Jumper; - 19th May 2009 at 15:00.
Thanks...there's some top tips there.
Just a thought here - is it even possible to get reliable results with mechanical switches & interupts?
By this I mean, a mechanical switch normally needs a debounce, else you'd get more than one interupt for every time the switch 'settled'? In my situation, it's importnat that there's just one 'trigger' for every revolution of the encoder wheel (so I can establish how many interupts/black stripes the PIC has counted over one rev)...if I used an interupt for the magnetic switch, there'd be a possibility of not just one interupt...but several in quick succession...which will cause a bit of 'fog' whilst trying to confirm that my wheel, circuit & PIC are all in sync & counting 48 stripes per turn!
By the way...I've now dabbled with Darrel's "Hello World" which will suit my encoder wheel needs perfectly....after wrestling with 'pin' polling for weeks with my encoder wheel & getting very erratic results, I'm one very happy McSpank here today! October 05, 2002 maybe was a good day...but I can say without any shadow of a doubt, for me the 19 May 2009 was a lot better!!
Just a couple of small suggestions for Darrel's website (to save avoid a lot of newbie-esque puzzlement) - on Darrel's very first hello world code page, it might be worth saying that a user will need to establish their own PIC variant's 'INT' pin, along with perhaps a couple of PIC specific examples. (it might be ovbious to you old hands, but looking at the plethora of pins PICs have, it wasn't obvious to me!)
Also, for what it's worth...the 16F690 is perhaps the most common chip that newbies come into contact with at the moment (on account it's bundled with Microchip's very popular PikKit2 starter kit)...I had a problem with Darrel's "Hello World" code when I first compiled ...."error: variable wsave3 position request 416 beyond ram_end 367.", ultimately meaning a line in Darrel's DT_INTS-14.bas file needed commenting out - that might also be worth a mention too? (or at least some mention on a FAQ page?)
Anyway, a hearty thanks to Darrel... without his effort towards making interupts easy with PICBasic , I'm sure I would have left interupts for another day (ie sometime in 2023!)
Last edited by HankMcSpank; - 19th May 2009 at 16:50.
Bookmarks