In SX Microcontrollers, SX/B Compiler and SX-Key Tool, loojade wrote: Hallo everybody, I have a dubt about interrupt configuration. I need to fix a SX28p to accept 3 external signal (from 3 proximity sensors). For every edge I have to check a counter value to define the time between pulses. I got the following code from SX-KEY help file. I think this is enough to detect the external pulses from the sensors. [code] ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ' ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "ISRPORTB" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- Buttons VAR RB ' button inputs TRIS_Btns VAR TRIS_B ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- sensor VAR Byte ' sensor conneted to RB.0, RB.1 and RB.2 A VAR Word counter1 VAR Word counter2 VAR Word counter3 VAR Word ' ------------------------------------------------------------------------- INTERRUPT ' ------------------------------------------------------------------------- ISR_Start: WKPND_B = sensor ' get which sensor cause the pulse Ch1: ' check channel IF sensor <> %0001 THEN Ch2 ' if not, try next A=counter1 conter1=0 GOTO ISR_Exit Ch2: IF sensor <> %0010 THEN Ch3 A=counter2 conter2=0 GOTO ISR_Exit Ch3: IF winner <> %0100 THEN Ch4 A=counter3 conter3=0 GOTO ISR_Exit ISR_Exit: WKEN_B = %11111111 ' no ISR until reset RETURNINT ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: WKPND_B = %00000000 ' clear pending WKED_B = %00000111 ' falling edge detect WKEN_B = %11111000 ' use bits 0..3 for inputs END [/code] Now I don't know How can I use the internal interrupts to incremement the counters (counter1, counter2 and counter3: 1 for each sensor). In SX-KEY help file I found the following code to repeat a function a specific times for second: [code] ' ------------------------------------------------------------------------- INTERRUPT 77_000 ' ------------------------------------------------------------------------- ISR_Start: INC counter1 INC counter2 INC counter3 RETURNINT [/code] How can I have both kind of interrupts in one program??? I'm not sure I can do this. Any help will be apreciate. Thanks in advance Loojade ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=250718 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)