Title: proton and interrupts (RB0) ... i have problems Post by: jeanninemtv 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... :( :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 Title: proton and interrupts (RB0) ... i have problems Post by: Wizpic 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 Title: i cant upload Post by: jeanninemtv 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 Title: proton and interrupts (RB0) ... i have problems Post by: Wizpic 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 Title: Please post your code Post by: Faros 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 .... Title: i solved it Post by: jeanninemtv 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... Title: proton and interrupts (RB0) ... i have problems Post by: Wizpic 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 Title: proton and interrupts (RB0) ... i have problems Post by: tasosstr 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 Title: try this Post by: Wizpic 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] Title: proton and interrupts (RB0) ... i have problems Post by: picstudent on December 15, 2005, 11:40:43 23:40 thanks i-ll try it and then i -ll show my own answer
Title: proton and interrupts (RB0) ... i have problems Post by: picstudent on December 15, 2005, 11:42:03 23:42 i have problems with the interrupts too!!! so i wish to make this on mikrobasic !
Title: proton and interrupts (RB0) ... i have problems Post by: Wizpic 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 Title: proton and interrupts (RB0) ... i have problems Post by: jeanninemtv 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!! |