The Godfather talking
You can run, but you can't hide.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 01, 2024, 06:32:02 06:32


Login with username, password and session length


Pages: [1]
Print
Author Topic: proton and interrupts (RB0) ... i have problems  (Read 13760 times)
0 Members and 1 Guest are viewing this topic.
jeanninemtv
Senior Member
****
Offline Offline

Posts: 311

Thank You
-Given: 57
-Receive: 25


« on: December 13, 2005, 11:13:23 23:13 »

hi, i'm making a little program on a 16f84a
 
an lcd working in 4 bit mode, 3 buttons:   ra1  ra2  and rb0
 
the lcd works on rb4...rb7  / rb3 rb2 ctrl lines
 
i select an time interval from 0 to 1000 ms
it shows that time on the lcd
and when i press rb0 it shots only a pulse with the specified duration.  ___|---|_
 
 
the problem is the following.
i run the bas on proteus and  i set up the "width " of the single pulse , the loop works ...
 
i press rb0
and the one shot pulse goes ok!!!
 
but
when pic returns from interrupt
it goes to hell
gets out of mainloop...
 Sad
 
:mad:  and when i press again rb0 .... it shots ok
 
but never returns to mainloop.
 
can anyone share any proton picbasic example code with RB0 ....?
 
please.
 
next thread i 'll put the code, and dsn files ...
 
thanks my friends
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #1 on: December 13, 2005, 11:16:46 23:16 »

show us your stuff we might be able to help show some sample of code
 
i might be able to help
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
jeanninemtv
Senior Member
****
Offline Offline

Posts: 311

Thank You
-Given: 57
-Receive: 25


« Reply #2 on: December 14, 2005, 01:47:03 01:47 »

hello.  i need to back to the main loop when the interrupt subroutine ends ...
 
note for :  i canot upload filess :confused:
 
i press upload button and appears
 
Forbidden

You don't have permission to access /forum/newattachment.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/1.3.34 Server at http://www.sonsivri.com Port 80
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #3 on: December 14, 2005, 02:07:23 02:07 »

looks like having trouble i konw you have sent me a pm but cant get it
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Faros
Senior Member
****
Offline Offline

Posts: 254

Thank You
-Given: 141
-Receive: 178


« Reply #4 on: December 14, 2005, 02:53:35 14:53 »

Hi ...
 
Please Post your code along with protues design file to be able to help you ... hope you will solve the upload problem soon ....
Logged
jeanninemtv
Senior Member
****
Offline Offline

Posts: 311

Thank You
-Given: 57
-Receive: 25


« Reply #5 on: December 15, 2005, 03:48:24 15:48 »

my original code ..
 
DEVICE 16F84A
DECLARE LCD_DTPIN PORTB.4
DECLARE LCD_RSPIN PORTB.3
DECLARE LCD_ENPIN PORTB.2
DECLARE LCD_LINES 1
'DECLARE FSR_CONTEXT_SAVE = ON
DIM TEMP AS WORD
SYMBOL RELAY PORTB.1
ON_HARDWARE_INTERRUPT ISRA
GOTO NO_INTA
ISRA:
HIGH RELAY
DELAYMS TEMP
LOW RELAY
INTCON.1=0
CONTEXT RESTORE


NO_INTA:
INTCON=$90
TRISB=1
PORTB=0
CLS
'              0000000001111111
'              1234567890123456
GOSUB SCREEN
NADA:
IF PORTA.1=0 THEN
TEMP=TEMP+1
ENDIF
IF PORTA.2=0 THEN
  IF TEMP=0 THEN
  GOTO SHOWME
  ENDIF
TEMP=TEMP-1
ENDIF
SHOWME:
GOSUB LACK
GOTO NADA

SCREEN:
PRINT AT 1,1 ,"TRIG:"
PRINT AT 1,15 ,"ms"
RETURN
LACK:
PRINT AT 1,10,DEC4 TEMP
DELAYMS 100
RETURN

END
 
 
i haven-t noted that delayms uses two opr three CALLs ...
 
that-s why my stack overflows quickly and i return to hell and not on the main loop.
 
i replaced it with a for   next   ...  with an delayms made in asm ....  to generate N x delayms ))))))
 
 
tif you have another suggest share it...
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #6 on: December 15, 2005, 07:06:14 19:06 »

I shall have a look into your code i can see what you want to do now but you may be better using on interrupt
 
Because a hardware interrupt may occur at any time, It cannot be fully guaranteed that a SYSTEM variable will not be disturbed while inside the interrupt handler, therefore, the safest way to use a HARDWARE interrupt is to write the code in assembler, or to implement a SOFTWARE interrupt using the  on interrupt directive. This will guarantee that no system variables are being altered.
 
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
tasosstr
Junior Member
**
Offline Offline

Posts: 75

Thank You
-Given: 95
-Receive: 14


« Reply #7 on: December 15, 2005, 09:21:52 21:21 »

Hello,

Is it a different
form :
   ON_HARDWARE_INTERRUPT ISRA
and from :
   On Interrupt

So you can Say :
On interrupt  goto ISRA

.
.
.
.

'Interrupt routine
Disable
ISRA:  
.
.
.
Resume  
Enable


Try this and tell me.

Best Regards,
Tasosstr
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #8 on: December 15, 2005, 09:47:05 21:47 »

jeanninemtv
 
Device 16F84

Declare LCD_DTPIN
[/color][/size]PORTB.4

Declare LCD_RSPIN [/color][/size]PORTB.3

Declare LCD_ENPIN [/color][/size]PORTB.2

Declare LCD_LINES [/color][/size]1

'DECLARE FSR_CONTEXT_SAVE = ON

[/color][/size]Dim TEMP As Word

Symbol
RELAY [/size]PORTB.1

ON_INTERRUPT
GoTo [/b]ISRA

' Assign some Interrupt associated aliases

[/color][/size]Symbol T0IE = [/size]INTCON.5 ' TMR0 Overflow Interrupt Enable

[/color][/size]Symbol T0IF = [/size]INTCON.2 ' TMR0 Overflow Interrupt Flag

[/color][/size]Symbol GIE = [/size]INTCON.7 ' Global Interrupt Enable

[/color][/size]Symbol PS0 = [/size]OPTION_REG.0 ' Prescaler ratio bit-0

[/color][/size]Symbol PS1 = [/size]OPTION_REG.1 ' Prescaler ratio bit-1

[/color][/size]Symbol PS2 = [/size]OPTION_REG.2 ' Prescaler ratio bit-2

[/color][/size]Symbol PSA = [/size]OPTION_REG.3 ' Prescaler Assignment (1=assigned to WDT 0=assigned to oscillator)

[/color][/size]Symbol T0CS = [/size]OPTION_REG.5 ' Timer0 Clock Source Select (0=Internal clock 1=External PORTA.4)

[/color][/size]Symbol LED = [/size]PORTB.1



GoTo NO_INTA [/size]' Jump over the interrupt subroutine

' Interrupt routine starts here

' Initiate the interrupt

[/color][/size]GIE = 0 ' Turn off global interrupts

[/color][/size]PSA = 0 ' Assign the prescaler to external oscillator

[/color][/size]PS0 = 1 ' Set the prescaler

[/color][/size]PS1 = 1 ' to increment TMR0

[/color][/size]PS2 = 1 ' every 256th instruction cycle

[/color][/size]T0CS = 0 ' Assign TMR0 clock to internal source

[/color][/size]TMR0 = 0 ' Clear TMR0 initially

[/color][/size]T0IE = 1 ' Enable TMR0 overflow interrupt

[/color][/size]GIE = 1 ' Enable global interrupts

[/color][/size]GoTo NO_INTA

ISRA:

High RELAY

DelayMS TEMP

Low RELAY

T0IF = [/size]0

Context Restore

NO_INTA:

[/size]INTCON=$90

TRISB=1

PORTB=0

Cls

[/size]' 0000000001111111

' 1234567890123456

[/color][/size]GoSub SCREEN

NADA:

If [/size]PORTA.1=0 Then

TEMP=TEMP+1

EndIf

If
[/size]PORTA.2=0 Then

If
TEMP=[/size]0 Then

GoTo
SHOWME

EndIf

TEMP=TEMP-1

EndIf

SHOWME:

GoSub LACK

GoTo NADA

SCREEN:

Print At [/size]1,1 ,"TRIG:"

Print At [/size]1,15 ,"ms"

Return

LACK:

Print At [/size]1,10,DEC4 TEMP

DelayMS
100

Return

End
 
 
Try that it should work if i have understood you i can alter the pules and see it change on scope
 
Just  let me know if it's ok or not
 
wizpic
[/size]
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
picstudent
Active Member
***
Offline Offline

Posts: 169

Thank You
-Given: 0
-Receive: 3


« Reply #9 on: December 15, 2005, 11:40:43 23:40 »

thanks i-ll try it and then i -ll show my own answer
Logged

... rego ... who are are you really ?
picstudent
Active Member
***
Offline Offline

Posts: 169

Thank You
-Given: 0
-Receive: 3


« Reply #10 on: December 15, 2005, 11:42:03 23:42 »

i have problems with the interrupts too!!!    so i wish to make this on mikrobasic !
Logged

... rego ... who are are you really ?
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #11 on: December 16, 2005, 12:08:32 00:08 »

Picstudent
 
Not sure about mikrobasic they do soem things differently i perfer PDS.
What are you trying to do ?
might be able to help
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
jeanninemtv
Senior Member
****
Offline Offline

Posts: 311

Thank You
-Given: 57
-Receive: 25


« Reply #12 on: December 23, 2005, 02:05:37 02:05 »

thanks, i have replaced delayms on interrupt subroutine with a            for   next and a single asm delay ..
 
 
all my troubles fixed
 
thanks!!
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC