Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Mikropascal to ASM ?

Status
Not open for further replies.
The way you have it at the moment the program runs top to bottom... when it reaches tempo it just continues right through to the return command...BUT where to return???

You have to STOP the program BEFORE it hits the tempo routine..

If you use " goto $ " ( same command ) the program will sit there waiting for interrupt signals
 
sorry, I do not understand!
I think I'll stop.
I find no solution.
thank you for your help,
thank you to everyone who tried to help me
 
There is no need to stop....Let e write a small program in asm to do what you need, then I'll comment it

Code:
	list p=16f84A
	#include p16f84A.inc
	__Config _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC
;................................................. ............




;******************** Variables utilisées ****************

var1 equ C
#define bphaut
#define bpbas
#define fchaut
#define fcbas


;********** Numero de version / données EEPROM ***********

	ORG h'2100'
	de "Version 1.0"

;************* definition des registres temporaires **********

retard1 EQU 0X0C ;le registre temporaire retard1 se trouve a l'adresse 0C
retard2 EQU 0X0F ;""""""""""""""""""""""""""""""""""""""""""""""""" """" 0F
retard3 EQU 0x10 ;""""""""""""""""""""""""""""""""""""""""""""""""" """" 0X10

;***************** Programme principal *******************

	ORG 0
	GOTO init

;*********** Sous Programme d 'interruption **********

	ORG 4

;*********** IT sur RB4-RB7***********************************
	movfw PORTB		; MUST READ PORTB TO CLEAR INTERRUPT
	bsf PORTA,0 		; on allume la led connectée sur ra0
	call tempo
	bcf PORTA,0
	movlw 0x88	 	; on raz le flag RBIF & GIE
	movwf INTCON
	retfie 			; retour d 'interruption


; *********** Programme d' INIT ***********************

init


	bsf INTCON,GIE 		; autorise les Interruptions
	bsf INTCON,RBIE 	; autorise l ' IT sur RB4-RB7
	bsf STATUS,5 		; on met à 1 le 5eme bit du registre status pour accéder
				; à la 2eme page mémoire ( pour trisa et trisb )
	MOVLW B'11111100' 	; programmation de rb0-rb7 
	MOVWF TRISB 		; on met 11110000 dans le registre de direction du port B 
	MOVLW B'00110'		; programmation de ra0-ra4 
	MOVWF TRISA 		; on met 00000 dans le registre de direction du port A 
	bcf STATUS,5 		; on remet à 0 le 5eme bit du registre status pour accéder
				; à la 1eme page mémoire 
	clrf PORTA 		; raz du port A
	clrf PORTB 		; raz du port B

; ***************** Début de votre Programme ***********************

	goto $			; Wait here forever!!!


;****************** Programme de temporisation ***********************


; modifier les valeurs dans retard1 retard2 et retard3 pour changer la temporisation

tempo
	MOVLW 0xFF 		; on met ff dans le registre W (selon la tempo souhaitée)
	MOVWF retard1 		; on met W dans le registre retard1
	MOVWF retard2 		; on met W dans le registre retard2
	MOVLW 0x12 		; on met 12 dans le registre W (selon la tempo souhaitée)
	MOVWF retard3 		; on met W dans le registre retard3
attente
	DECFSZ retard1,F 	; on décrémente retard1 et on saute la prochaine instruction si
	GOTO attente 		; le registre retard1 = 0 sinon retour à attente
	movlw 0xFF 		; on recharge retard1 (selon la tempo souhaitée)
	movwf retard1
	DECFSZ retard2,F 	; on décrémente retard2 et on saute la prochaine instruction si
	GOTO attente 		; le registre retard2 = 0 sinon retour à attente
	movlw 0xFF 		; on recharge retard2 (selon la tempo souhaitée)
	movwf retard2
	DECFSZ retard3,F 	; on décrémente retard3 et on saute la prochaine instruction si
	GOTO attente 		; le registre retard3 = 0 sinon retour à attente
	RETURN 			; retour au programme principal après l 'instruction CALL

end ; fin du programme

end

This does what you need... RBIF will only clear once read...
 
Last edited:
thank you for your support.

I just made the changes you advised me.
syntax "goto &" seems to be a problem?
when compiling with MPLAB, I board this message

goto & -->

Error[128] .ASM 79 : Missing argument(s)
BUILD FAILED
 
Last edited:
goto $ , does not change the problem, compile with or without
ok first INT, second INT bad ...
I'll put here the program as currently
$ goto is not

Code:
;************   Directive d' assemblage pour MPLAB  ***********

     list    p=16f84A
     #include p16f84A.inc
     __Config _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC
;.............................................................




;********************   Variables utilisées  ****************

var1    equ  C
#define bphaut
#define bpbas
#define fchaut
#define fcbas


;**********   Numero de version / données EEPROM  ***********

      ORG h'2100'
      de "Version 1.0"

;*************    definition des registres temporaires  **********

retard1  EQU 0X0C  ;le registre temporaire retard1 se trouve a l'adresse 0C
retard2  EQU 0X0F  ;""""""""""""""""""""""""""""""""""""""""""""""""""""" 0F
retard3  EQU 0x10  ;""""""""""""""""""""""""""""""""""""""""""""""""""""" 0X10

;*****************   Programme principal  *******************

   ORG 0
   GOTO init

;***********  Sous  Programme d 'interruption   **********

   ORG 4

;*********** IT sur RB4-RB7***********************************

   movfw PORTB         ;lecture du portB pour effaçement de l'interruption
   bsf PORTA,0         ; on allume la led connectée sur ra0
   call tempo
   bcf PORTA,0
   movlw 0X88          ; on raz le flag RBIF & GIE
   bcf INTCON,RBIF     ; on raz le flag RBIF
   bcf INTCON,RBIE
   retfie              ; retour d 'interruption


; ***********  Programme d' INIT ***********************

init

   
   bsf INTCON,GIE           ; autorise les Interruptions
   bsf INTCON,RBIE          ; autorise l ' IT sur RB4-RB7
   bsf STATUS,5             ; on met à 1 le 5eme bit du registre status pour accéder
                            ; à la 2eme page mémoire ( pour trisa et trisb )
   MOVLW B'11111100'        ; programmation de rb0-rb7 
   MOVWF TRISB              ; on met 11110000 dans le registre de direction du port B 
   MOVLW B'00110'           ; programmation de ra0-ra4 
   MOVWF TRISA              ; on met 00000 dans le registre de direction du port A 
   bcf STATUS,5             ; on remet à 0 le 5eme bit du registre status pour accéder
                            ; à la 1eme page mémoire  
   clrf PORTA               ; raz du port A
   clrf PORTB               ; raz du port B

; ***************** Début de Programme ***********************

  

debut

   BTFSS PORTA,2  ; bouton haut appuyé ? ,sinon on continu
   goto  suite
   movlw B'00000001'
   movwf PORTB
   call tempo
   bcf  PORTB,0

suite

   BTFSS PORTA,1  ; bouton bas appuyé ? sinon on continu
   goto debut
   movlw B'00000010'
   movwf PORTB
   call tempo
   bcf  PORTB,1

   
   goto debut


   

;******************   Programme de temporisation  ***********************


tempo
       MOVLW 0xFF            ; on met ff dans le registre W (selon la tempo souhaitée)
       MOVWF retard1         ; on met W dans le registre retard1
       MOVWF retard2         ; on met W dans le registre retard2
       MOVLW 0x12            ; on met 12 dans le registre W (selon la tempo souhaitée)
       MOVWF retard3         ; on met W dans le registre retard3
attente
       DECFSZ retard1,F      ; on décrémente retard1 et on saute la prochaine instruction si
       GOTO  attente         ; le registre retard1 = 0 sinon retour à attente
       movlw 0xFF            ; on recharge retard1 (selon la tempo souhaitée)
       movwf retard1
       DECFSZ retard2,F      ; on décrémente retard2 et on saute la prochaine instruction si
       GOTO  attente         ; le registre retard2 = 0 sinon retour à attente
       movlw 0xFF            ; on recharge retard2 (selon la tempo souhaitée)
       movwf retard2
       DECFSZ retard3,F      ; on décrémente retard3 et on saute la prochaine instruction si
       GOTO  attente         ; le registre retard3 = 0 sinon retour à attente
       RETURN                ; retour au programme principal après l 'instruction CALL

       end                   ; fin du programme
 
Last edited:
You cannot have a delay in the main and also the ISR.....Reason...imagine your program is currently in the delay routine..... then your ISR kicks in.. it will clear all the variables in the delay routine and start again......When the ISR is finished all three delay variables are now 0,0 and 0, The ISR returns EXACTLY where it left off... but now all variables will count down... well over 30 minutes... You keep testing the ISR it keeps resetting and resetting..... forever...
 
Status
Not open for further replies.

Latest threads

Back
Top