PDA

View Full Version : Sorry to Interrupt



NewBoy
18th January 2006, 06:39
Can you help a new boy to Proton please?

I'm changing over from PICAXE and I'm having a little brain-brown-out concerning converting lines from PICAXE Basic to Proton.

Subject: Interrupts.

PICAXE only has one interrupt command from the compiler. It has the format:
SETINT input, mask.
'Input' defines which pin(s) is/are to be looked at.
'Mask' defines whether the interrupt should trigger on a 0 or 1 event.
Eg. to interrupt on input1 HIGH only
SETINT %00000010,%00000010
A typical use would be buttons or external logic input.

I'm a bit confused as in how to translate into the much more flexible Proton Basic.

I've read the Help but need a little shove to get the cerebellum glowing.

A few example lines would start me - and I'd be very, very grateful.

Tim
18th January 2006, 07:02
I'm unsure how picaxe handles its interrupts but considering what you have said It looks like there a software variant. Because pics have spacific pins that you can get an interrutpt to be generated on. Mostly its Portb.0 and PortB.4-7. To be able to select any pin via a mask means the interrupt routine must be being polled so it can check the ports.

Along with some of the pins on PortB you can of cause add a number of other sources like data on the Usart and timers overflowing.

If you can say what you want to do then we can give you the correct code.

NewBoy
18th January 2006, 08:11
Thanks.

Example: PIC16F88 (18pin DIL)

Inputs on PortA. 0,1,2,3,6,7.
Push-buttons connected on 6 and 7. (physical pins 16 and 17 I think)
Pins held loosely high, push-buttons pull pins down to ground.
I.e. the pins are normally high and the buttons bring them low.

I want to be able to pop into (hopefully) 2 different Subroutines when buttons are pressed on a soft interrupt.
Call the subs ButtA: and ButtB: (original huh?)

Thats enough to get me rolling.
Much appreciated.

Tim
18th January 2006, 08:34
How quickly do you want to respond to the button press's and what kind of code do you want to run in them.

If it's just an input button then 100 x a second would do I would think.

Because it's not a true interrupt I'm thinking you just need to do some polling.

NewBoy
18th January 2006, 08:52
Thanks Tim.

Speed is not hugely critical. I could poll. But I was also trying to get a handle on interrupt methods and learn how to do it at the same time for other apps in the future. (Keen to learn!)

As there will be quite a few times buttons need to be pressed (later in the code) I was assuming it would save some lines too(??)

A slight aside:-
P.S. Any ideas how to switch the Brown-Out detect off to save power?
I'm sure I saw something under Declare but I can't find it now. I'll stop asking questions now...

Frank.

C_Moore
18th January 2006, 11:07
Hi NewBoy,

I'm a former Picaxer.Using the 16F88 pics can be tricky sometimes. To disable brown out detect or any other fuses use the Config declare.for example

CONFIG HS_OSC,MCLR_OFF,BODEN_OFF...... and so on. Open PDS and then open the 16F88.LPB located in C:\ProgramFiles\Crownhill\inc.Scroll down and you will see all the config fuses.Also Take a look at
the datasheet for setting the Analog pins to Digital using the ANSEL register. This may seem a bit over whelming,but you will understand it soon.

NewBoy
18th January 2006, 11:30
Thanks Charlie.

I shall investigate.

I assume I won't break anything by mistake? i.e. setting something irreversibley?
PDS gives so much more access and so there are many new things to twiddle (as I'm not an assembler person).

Regards.

C_Moore
18th January 2006, 21:07
Hi NewBoy,

No,you won't break anything.have fun.:)

NewBoy
19th January 2006, 11:15
Excellent. Thanks. If you smell burning PICs Charlie, that'll be me!

Tim,
Any advice on that little query about interrupting on button presses?
(Obviously the 'button presses' could also be an external logic pulse on those pins - button pressing was just what I was going to do at the moment).

It was just that I couldn't see how to make the interrupt specific to a pin e.g. mask it or similar. Or do I have to get the code to respond to a 'general' interrupt and then look to see what has actually casued the interrupt i.e. a 2 stage process?

Proton is very new to me and I have already gone cross-eyed trawling through the Help (which, may I add, is superbly comprehensive).

I sincerely appreciate the help and advice.

fanie
19th January 2006, 12:06
If I may also lay an egg here - Hardware Interrupts are really cool things to use as your software is not responsible for seeing an input come, the hardware does ! It basically means that you can detect an input faster with hardware than what the software can dream to poll - especially if you have the pic do a lot of other things too.

The Interupt Man (TIM for short) is the best to give you S/Ware advice on this ! Over to you Tim.

NewBoy
19th January 2006, 21:06
Your 'egg' is appreciated.
I was hoping Tim would reply. Perhaps he has been interrupted and gone off into a subroutine...