PDA

View Full Version : STATUS re-curtain W



zugvogel1
- 12th February 2005, 15:57
STATUS re-curtain W and

needs still help with these order.

bcf INTCON,INTF
swapf STATUS_TEMP,W
movwf STATUS
SWAPF W_TEMP,F
SWAPF W_TEMP,W
retfie

Dick M
- 12th February 2005, 20:07
I'm not sure what you are trying to do. If you are trying save the registers in your interrupt routine then here is how I do it.


movwf _w_save ; Save W register
swapf STATUS,W ; Swap status to be saved into W
movwf _s_save ; Save STATUS register
movfw PCLATH
movwf _p_save ; Save PCLATH


place your clr interrupt flag and other code here

Then restore registers before returning from interrupt

movfw _p_save
movwf PCLATH ; Restore PCLATH
swapf _s_save,W
movwf STATUS ; Restore STATUS register - restores bank
swapf _w_save,F
swapf _w_save,W ; Restore W register

NavMicroSystems
- 12th February 2005, 20:34
Zugvogel1 & Dick M,

This is the Pic Basic Pro Category on the Pic Basic Forum.

What you are discussing here should be in the Off Topic category.

Zugvogel1

Why are you starting a new thread every time you have a question regarding a topic you have already posted?

zugvogel1
- 13th February 2005, 12:24
Hello Ralf

I did not want to have help asm-Befehle know whether for these two variables also this can write in pic Basic.

F var byte
W var byte

or whether there are other commands for that.

A lot thanks to already once

zugvogel1
- 13th February 2005, 14:52
;Interupt Service Routine ISR

Meine frage ist ob mann in Pic-Basic die Interupt Service Routine ISR
so auch einleiten muß oder nicht

;Saving STATUS and W

@ movwf W_TEMP ; W-Register Retten
@ swapf STATUS,W ; Status-Reg. -> w
@ movwf STATUS_TEMP ; Status-Reg. Retten

......mein code

und so beenden muß

@ swapf STATUS_TEMP,W ; in w-Register
@ movwf STATUS ; w -> Status
@ SWAPF W_TEMP,F ; W_TEMP -> W, ohne..
@ SWAPF W_TEMP,W ; .. Z-Flag zu aendern

retfie
--------------------------------------------------------




Service ;Interupt routine ISR

Mine is asked whether mann in pic Basic the service Interupt must introduce routine ISR or not

STATUS ;Saving W and

@ movwf W_TEMP
@ swapf STATUS,W
@ movwf STATUS_TEMP

... ... my code

and end

@ swapf STATUS_TEMP,W
@ movwf status
@ SWAPF W_TEMP,F
@ SWAPF W_TEMP,W

retfie

zugvogel1
- 13th February 2005, 15:21
Ich werde deine Tip (PICtron) annehmen bin neu hier muß noch lernen.

Also wie gesagt ich möchte gern mit meinem neuen
compiler mal rum spielen und will dieses einfache files auf picbasic mal umstellen.

s88.ASM im anhang

s88.bas

und soweit bin ich schon vorgetrungen nun komme ich aber nicht weiter

;---------Files Assignment

SYMBOL C = STATUS.0 ' Carry bit
;PortA
SYMBOL RA0 = PORTA.0 ' Bi-directional I/O port
SYMBOL RA1 = PORTA.1 ' Bi-directional I/O port
SYMBOL RA2 = PORTA.2 ' Bi-directional I/O port
SYMBOL RA3 = PORTA.3 ' Bi-directional I/O port
SYMBOL RA4 = PORTA.4 ' Bi-directional I/O port
SYMBOL RA5 = PORTA.5 ' Bi-directional I/O port
SYMBOL RA6 = PORTA.6 ' Bi-directional I/O port
SYMBOL RA7 = PORTA.7 ' Bi-directional I/O port
;PortB
SYMBOL B_CLK = PORTB.0 ' Bi-directional I/O port
SYMBOL B_OUT = PORTB.1 ' Bi-directional I/O port
SYMBOL B_LED = PORTB.2 ' Bi-directional I/O port
SYMBOL B_IN = PORTB.6 ' Bi-directional I/O port
SYMBOL B_PS = PORTB.7 ' Bi-directional I/O port
;INTCON
SYMBOL RBIF = INTCON.0 ' RB Port Interrupt Flag
SYMBOL INTF = INTCON.1 ' RB0 External Interrupt Flag
SYMBOL T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
SYMBOL RBIE = INTCON.3 ' RB Port Change Interrupt Enable
SYMBOL INTE = INTCON.4 ' RB0 External Interrupt Enable
SYMBOL T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
SYMBOL PEIE = INTCON.6 ' Peripheral Interrupt Enable
SYMBOL GIE = INTCON.7 ' Global Interrupt Enable
;CMCON
SYMBOL CM0 = CMCON.0 ' Comparator mode selection bits
SYMBOL CM1 = CMCON.1 ' Comparator mode selection bits
SYMBOL CM2 = CMCON.2 ' Comparator mode selection bits
SYMBOL CIS = CMCON.3 ' Comparator Input Switch
SYMBOL C1INV = CMCON.4 ' Comparator 1 output inversion
SYMBOL C2INV = CMCON.5 ' Comparator 2 output inversion
SYMBOL C1OUT = CMCON.6 ' Comparator 1 output
SYMBOL C2OUT = CMCON.7 ' Comparator 2 output
;OPTION_REG
SYMBOL PS0 = OPTION_REG.0 ' Prescaler Rate Select
SYMBOL PS1 = OPTION_REG.1 ' Prescaler Rate Select
SYMBOL PS2 = OPTION_REG.2 ' Prescaler Rate Select
SYMBOL PSA = OPTION_REG.3 ' Prescaler Assignment
SYMBOL T0SE = OPTION_REG.4 ' TMR0 Source Edge Select
SYMBOL T0CS = OPTION_REG.5 ' TMR0 Clock Source Select
SYMBOL INTEDG = OPTION_REG.6 ' Interrupt Edge Select
SYMBOL NOT_RBPU = OPTION_REG.7 ' PORTB Pull-up Enable

bit0 var R_DATEN.0 ;ist bit0 von R_DATEN
bit1 var R_DATEN.1 ;ist bit1 von R_DATEN
bit2 var R_DATEN.2 ;ist bit2 von R_DATEN
bit3 var R_DATEN.3 ;ist bit3 von R_DATEN
bit4 var R_DATEN.4 ;ist bit4 von R_DATEN
bit5 var R_DATEN.5 ;ist bit5 von R_DATEN
bit6 var R_DATEN.6 ;ist bit6 von R_DATEN
bit7 var R_DATEN.7 ;ist bit7 von R_DATEN

R_DATEN var Byte

ASM
R_DATEN equ 20h ; fuer Speichern der Daten und Schieben
R_OLD equ 25h ; Register for old values
R_FLAG equ 26h ; Register for flags

F_PS_RDY equ d'1' ; Ready-Flag

W_TEMP equ h'40' ; saving W-Register
STATUS_TEMP equ h'41' ; saving Status-Register

;------------Bit Assignment

;B_PS equ d'7' ; Port B, PS-Eingang
B_OUT equ d'1' ;Output ; Port B, Data-OUT
;B_IN equ d'6' ; Port B, Data-IN
;A_LED equ d'2' ;Output ; Port A, LED-Ansteuerung
;B_CLK equ d'0' ; Port B, Clock
endasm

goto start
;--------Service Routine ISR
@ org 0004h ; Interupt Vector

; ----- Saving STATUS and W ----------------------
@ movwf W_TEMP ; W-Register Retten
@ swapf STATUS,W ; Status-Reg. -> w
@ movwf STATUS_TEMP ; Status-Reg. Retten

; ----- IR IB0-Change (negative Edge) ------------
IF INTF = 0 then
goto ir_2
else
InTF = 0
endif
@ btfss R_DATEN,0 ; sofort Ausgabe des
@ bsf PORTB,B_OUT ; .. Bits #0 von
@ btfsc R_DATEN,0 ; .. R-Daten an
@ bcf PORTB,B_OUT ; .. DATA_OUT (invertiert)

If B_CLK <>1 then
B_LED =0
else
toggle B_LED
endif
If B_PS =0 then gosub lesen
if B_in <> 1 then
C =1
Else
C =0
Endif
@ rrf R_DATEN,F ; Daten nachschieben (invertiert)

; ----- IR by Timer 0 (idle-state) ------------
ir_2:
IF T0IF = 0 then
goto posret
else
T0IF =0
Endif
PORTA = ~PORTA ;alle Bits werden invertiert

; ----- Restore STATUS and W ---------------------
posret:
InTF = 0
@ swapf STATUS_TEMP,W ; in w-Register
@ movwf STATUS ; w -> Status
@ SWAPF W_TEMP,F ; W_TEMP -> W, ohne..
@ SWAPF W_TEMP,W ; .. Z-Flag zu aendern

retfie

;--------Programm
@ org 0060h ; Position des Programms

start:
;-------------Konfiguration PORTS

B_CLK =1
PortB = %11111111
TRISB = %11000001
TRISA = %11111111
CMCON =%00000111
OPTION_REG =%10000111
T2CON =%00000000
INTCON =%11110000
PIE1 =%00000000

;-------------Main Loop

loop:
CLEARWDT ; Watchdog-Timer loeschen
if B_PS =1 then goto loop2 ; if PS = 1
@ btfsc R_FLAG,F_PS_RDY ; and PS_RDY not set
goto loop
@ movf R_OLD,W ; .. the reload old values
@ movwf R_DATEN ;
@ bsf R_FLAG,F_PS_RDY ; .. set FLAG PS_RDY
goto loop
loop2:
@ bcf R_FLAG,F_PS_RDY ; if PS = LOW reset PS_RDY
goto loop


;---------Routine:lesen

lesen:
@ clrf R_DATEN
IF RA2 =1 then
Bit0 =0
Else
;Bit0 =1
@ bsf R_DATEN,0
endif
IF RA3 =1 then
Bit1 =0
Else
;Bit1 =1
@ bsf R_DATEN,1
endif
IF RA4 =1 then
Bit2 =0
Else
;Bit2 =1
@ bsf R_DATEN,2
endif
IF RA5 =1 then
Bit3 =0
Else
;Bit3 =1
@ bsf R_DATEN,3
endif
IF RA6 =1 then
Bit4 =0
Else
;Bit4 =1
@ bsf R_DATEN,4
endif
IF RA7 =1 then
Bit5 =0
Else
;Bit5 =1
@ bsf R_DATEN,5
endif
IF RA0 =1 then
Bit6 =0
Else
;Bit6 =1
@ bsf R_DATEN,6
endif
IF RA1 =1 then
Bit7 =0
Else
;Bit7 =1
@ bsf R_DATEN,7
endif

@ movf R_DATEN,W
@ movwf R_OLD

return

END


so und gehts nicht weiter in files.
ich wollte noch die resrlichen befehle mit @....
umwandeln in Pic-Basic

dank an alle