• AVR Freaks

Hot!Pic 16F15344 and Max7219 to drive 7 segment display in asm

Page: < 123 Showing page 3 of 3
Author
1and0
Access is Denied
  • Total Posts : 10902
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/11 12:48:49 (permalink)
0
The alchmiste
 
; CONFIG3
; __config 0xFFFF
; __CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_SC


Perhaps uncomment this config line and disable the watchdog.
 
#41
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/12 06:43:11 (permalink)
0
Hi 1 and 0,
 
Thanks for your comment.
I've tried as well and still the same behaviour (picture attached).
Have you already used this Pic I suspect that there will be a tricky think as I've aleady made the test on pic 16f887 and I've not encountered any problem.
post edited by The alchmiste - 2018/08/12 06:45:07

Attached Image(s)

#42
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/12 08:10:25 (permalink)
0
Hi guys,
 
I think I found out the issue.
It was due to the breadboard apparentely, I'll try with the 7 segment driver code and let you update.
Attached you can see the scope on pin RB4 (delay output) and the CLKOUT on pin RA4.

Attached Image(s)

#43
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/14 19:54:00 (permalink)
0
;
; File: tests.asm
; MPASM assembler/MPLINK linker example - file 1
; 3 Aug 2018
; Updated:
;


   list p=16f15344 , r=dec
 #include <p16f15344.inc>


; CONFIG1
; __config 0x8007, 0x2E8C
 __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_ON & _CSWEN_ON & _FCMEN_ON
; CONFIG2
 __CONFIG 0x8008, 0x251D
; __CONFIG _CONFIG2, _MCLRE_OFF & _PWRTE_ON & _LPBOREN_ON & _BOREN_NSLEEP & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_OFF
 CONFIG3
 __CONFIG 0x8009, 0x3F9F
;__CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC
; CONFIG4
 __CONFIG 0x800A, 0x1FE0
; __CONFIG _CONFIG4, _BBSIZE_BB64K & _BBEN_ON & _SAFEN_ON & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
; CONFIG5
; __config 0x3FFF
 __CONFIG _CONFIG5, _CP_OFF

 
 #Define Compteur1 0x22
        #Define Compteur2 0x23
 #Define Compteur3 0x24
 #Define etat 0x25,1


 Org 0x00

 Goto initialisation
 
 
initialisation
 banksel OSCCON1
 movlw 0x60
 movwf OSCCON1
 banksel TRISB
 movlw 0xEF
 movwf TRISB
 Goto start
start
 btfss etat
 goto allumer
 goto eteindre
allumer
 bsf etat
 banksel PORTB
 bsf PORTB,4
 goto timmer
eteindre
 bcf etat
 banksel PORTB
 bcf PORTB,4
 goto timmer
 
timmer
     banksel Compteur1
     movlw 0
     movwf Compteur1
     banksel Compteur2
     movlw 10
     movwf Compteur2
     banksel Compteur3
     movlw 1
     movwf Compteur3
boucle
     banksel Compteur1
     Decfsz Compteur1
     goto boucle

     banksel Compteur2
     Decfsz Compteur2
     Goto boucle

     banksel Compteur3
     Decfsz Compteur3
     Goto boucle
     Goto start
 end
Hi guys,
 
Do anyone understand why I get something looking like a reset on the OSC output every 2msec?
This lead to stop my program while runing
I've reviewed again and again config word and don't see any reason of reset.
 
Thanks
The alchimiste
post edited by The alchmiste - 2018/08/14 19:58:03

Attached Image(s)

#44
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/14 20:12:34 (permalink)
0
Why are you using the nice "verbose" format for CONFIG1 and CONFIG2,
but hard coded magic numbers for CONFIG3 and CONFIG4, with the verbose format commented out?
You also have a label "CONFIG3" in the middle there that should be commented out, but is not.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#45
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/14 20:21:45 (permalink)
0
qɥb
Why are you using the nice "verbose" format for CONFIG1 and CONFIG2,
but hard coded magic numbers for CONFIG3 and CONFIG4, with the verbose format commented out?
You also have a label "CONFIG3" in the middle there that should be commented out, but is not.
 


Hi qɥb , I did it because I was reviewing bit by bit to make sure all is correctely seteled, and the nice verbose was generated automatically by Mplab x.
Do you think I should use only one format?
I just noticed for the config 3, I made test again and it's not making any change

Attached Image(s)

#46
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/14 21:55:47 (permalink)
0
The alchmiste
Hi qɥb , I did it because I was reviewing bit by bit to make sure all is correctely seteled, and the nice verbose was generated automatically by Mplab x.
Do you think I should use only one format?

Yes. Stick with the verbose format.
Twiddling directly with hex numbers is too error prone, and prevents others from easily reviewing your settings.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#47
MBedder
Circuit breaker
  • Total Posts : 6886
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/15 00:37:41 (permalink)
0
The alchmisteDo anyone understand why I get something looking like a reset on the OSC output every 2msec? This lead to stop my program while runing
Feed your watchdog regularly, otherwise it will bite you.


#48
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/15 01:04:29 (permalink)
0
The WDT does appear to be disabled.
 
I did notice one bug. The "etat" variable is not in the global region, but there are no BANKSEL directives when it is accessed.

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#49
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/15 03:52:12 (permalink)
0
n
post edited by The alchmiste - 2018/08/15 04:08:32
#50
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/15 04:05:48 (permalink)
0
;
; File: tests.asm
; MPASM assembler/MPLINK linker example - file 1 
; 15 Aug 2018
; Updated: 
;


   list p=16f15344 , r=dec
 #include <p16f15344.inc>


; CONFIG1
; __config 0x3E8C
 __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_ON & _CSWEN_ON & _FCMEN_ON
; CONFIG2
; __config 0x253C
 __CONFIG _CONFIG2, _MCLRE_OFF & _PWRTE_ON & _LPBOREN_OFF & _BOREN_OFF & _BORV_HI & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_OFF
; CONFIG3
; __config 0x3F9F
 __CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC
; CONFIG4
; __config 0x1FF8
 __CONFIG _CONFIG4, _BBSIZE_BB64K & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
; CONFIG5
; __config 0x3FFF
 __CONFIG _CONFIG5, _CP_OFF

 
 #Define Compteur1 0x22
        #Define Compteur2 0x23
 #Define Compteur3 0x24
 #Define etat 0x25


 Org 0x00

 Goto initialisation
 
 
initialisation
 banksel OSCCON1
 movlw 0x60
 movwf OSCCON1
 banksel TRISB
 movlw 0xEF
 movwf TRISB
 Goto start
start 
 banksel etat
 btfss etat,1
 goto allumer
 goto eteindre
allumer 
 banksel etat
 bsf etat,1
 banksel PORTB
 bsf PORTB,4
 goto timmer
eteindre
 banksel etat
 bcf etat,1
 banksel PORTB
 bcf PORTB,4
 goto timmer
 
timmer 
     banksel Compteur1
     movlw 0
     movwf Compteur1
     banksel Compteur2
     movlw 20
     movwf Compteur2
     banksel Compteur3
     movlw 1
     movwf Compteur3
boucle
     banksel Compteur1
     Decfsz Compteur1
     goto boucle

     banksel Compteur2
     Decfsz Compteur2
     Goto boucle

     banksel Compteur3
     Decfsz Compteur3
     Goto boucle
     Goto start
end
MBedder
The alchmisteDo anyone understand why I get something looking like a reset on the OSC output every 2msec? This lead to stop my program while runing
Feed your watchdog regularly, otherwise it will bite you.




Hi Mbedder, yes as qɥb mentioned, it is disabled. so the dog for the moment shouled be leashed no risks
qɥb
The WDT does appear to be disabled.
 
I did notice one bug. The "etat" variable is not in the global region, but there are no BANKSEL directives when it is accessed.




good catch, I've updated the code with config format in verbose format and added the banksel for etat.
As the builder was telling my that "," was an illegal caracter, I've defined "etat" as a byte instead of a bit.
For the moment still the same observation on my analyzer.
Any other idea?
#51
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/15 05:54:34 (permalink)
0
You have brownout detect enabled. Maybe there is a regular glitch in Vdd that it is picking up.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#52
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/15 05:59:09 (permalink)
0
qɥb
You have brownout detect enabled. Maybe there is a regular glitch in Vdd that it is picking up.
 


I've pute it it off in my last post just in case:
; CONFIG2
; __config 0x253C
 __CONFIG _CONFIG2, _MCLRE_OFF & _PWRTE_ON & _LPBOREN_OFF & _BOREN_OFF & _BORV_HI & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_OFF
 
#53
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2018/08/15 15:26:53 (permalink)
0
   list p=16f15344 , r=dec
 #include <p16f15344.inc>


; CONFIG1
; __config 0x3E8C
 __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_ON & _CSWEN_ON & _FCMEN_ON
; CONFIG2
; __config 0x279C
 __CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_NSLEEP & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_OFF
; CONFIG3
; __config 0xFFFF
 __CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC
; CONFIG4
; __config 0x1FE0
 __CONFIG _CONFIG4, _BBSIZE_BB64K & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
; CONFIG5
; __config 0x3FFF
 __CONFIG _CONFIG5, _CP_OFF

; _RSTOSC_HFINT1 -> permet l'activation de l'oscillateur interne a une frequence de 1Mhz soit 1 microS/osccillation
; _LVP_OFF -> permet la programmation a faible tenssion
; _CP_OFF -> Ne cache pas le code
; _WDT_OFF -> Desactive le Watch Dog


; TODO PLACE VARIABLE DEFINITIONS GO HERE

;***** VARIABLE DEFINITIONS at the bank 0 begining at adress 0x20
cblock 0X20
registre_Démarrage : 1
Donnée_Démmarrage : 1
Donnée_Fin : 1

registre_Parametrage : 1
Donnée_ParametrageBCD : 1

registre_Intensite : 1
Donnée_Intensite : 1

registre_nbrDigit : 1
Donnée_nbrDigit : 1

registre_Test : 1
Donnée_Test : 1

registre_Digit : 1
Donnée_Digit : 1

registre : 1
donnee : 1
endc
;*******************************************************************************
; Reset Vector
;*******************************************************************************

org 00H ; processor reset vector
goto START ; go to beginning of program

; TODO INSERT ISR HERE

;*******************************************************************************
; MAIN PROGRAM
;*******************************************************************************


START

; Initialisaton des variables


banksel registre_Démarrage
movlw 0x0c
movwf registre_Démarrage
 
banksel Donnée_Démmarrage
movlw 0x03
movwf Donnée_Démmarrage

banksel registre_Parametrage
movlw 0x09
movwf registre_Parametrage

banksel Donnée_ParametrageBCD
movlw 0x0F
movwf Donnée_ParametrageBCD

 
banksel registre_Intensite
movlw 0x0A
movwf registre_Intensite
 
banksel Donnée_Intensite
movlw 0x07
movwf Donnée_Intensite

 
banksel registre_nbrDigit
movlw 0x0B
movwf registre_nbrDigit
 
banksel Donnée_nbrDigit
movlw 0x03
movwf Donnée_nbrDigit

banksel registre_Test
movlw 0x0F
movwf registre_Test

banksel Donnée_Test
movlw 0x01
movwf Donnée_Test

 
banksel registre_Digit
movlw 0x01
movwf registre_Digit

banksel Donnée_Digit
movlw 0x01
movwf Donnée_Digit



; Initialisation des paramettres SPI

banksel RB4PPS
movlw 0x16 ;On associe SDO a RB4 ( les données transmises)
movwf RB4PPS

banksel RB5PPS
movlw 0x15 ;On associe SCK a RB5 (l'horloge)
movwf RB5PPS

banksel TRISB
movlw B'10001111' ;RB4 et RB5 et RB6 en sortie tout le rest en entrée
movwf TRISB

Banksel SSP1STAT ; On parametre l'horloge et l'echantillonage des données
movlw 0x40
movwf SSP1STAT

banksel SSP1CON1
movlw 0x20 ;On active le SPI
movwf SSP1CON1




banksel PORTB
clrf PORTB ;on efface les valeurs du port B


; Debut du parametrage Driver
;1
banksel registre_Démarrage
movf registre_Démarrage,w
banksel registre
movwf registre

banksel Donnée_Démmarrage
movf Donnée_Démmarrage,w
banksel donnee
movwf donnee
call RoutineveriffinSDI


;2
banksel registre_Parametrage
movf registre_Parametrage,w
banksel registre
movwf registre

banksel Donnée_ParametrageBCD
movf Donnée_ParametrageBCD,w
banksel donnee
movwf donnee
call RoutineveriffinSDI


;3
banksel registre_Intensite
movf registre_Intensite,w
banksel registre
movwf registre

banksel Donnée_Intensite
movf Donnée_Intensite,w
banksel donnee
movwf donnee
call RoutineveriffinSDI



;4
banksel registre_nbrDigit
movf registre_nbrDigit,w
banksel registre
movwf registre

banksel Donnée_nbrDigit
movf Donnée_nbrDigit,w
banksel donnee
movwf donnee
call RoutineveriffinSDI



;5
banksel registre_Test
movf registre_Test,w
banksel registre
movwf registre

banksel Donnée_Test
movf Donnée_Test,w
banksel donnee
movwf donnee
call RoutineveriffinSDI

banksel registre_Test
movf registre_Test,w
banksel registre
movwf registre

banksel donnee
movlw 0x00 ;fin du test
movwf donnee
call RoutineveriffinSDI

; Debut du programme envoie des chiffres

; Chiffre 1

movlw 0x01
banksel registre
movwf registre

banksel donnee
movlw 0x01
movwf donnee
call RoutineveriffinSDI

; Chiffre 2

movlw 0x02
banksel registre
movwf registre

banksel donnee
movlw 0x09
movwf donnee
call RoutineveriffinSDI



; Chiffre 3

movlw 0x03
banksel registre
movwf registre

banksel donnee
movlw 0x09
movwf donnee
call RoutineveriffinSDI


; Chiffre 4

movlw 0x04
banksel registre
movwf registre

banksel donnee
movlw 0x01
movwf donnee
call RoutineveriffinSDI
sleep

RoutineveriffinSDI
banksel PORTB
bcf PORTB,6

banksel registre
movf registre,w
banksel SSP1BUF
movwf SSP1BUF
banksel SSP1STAT
btfss SSP1STAT,0
goto $-1
banksel SSP1BUF
movf SSP1BUF,w

banksel donnee
movf donnee,w
banksel SSP1BUF
movwf SSP1BUF
banksel SSP1STAT
btfss SSP1STAT,0
goto $-1
banksel SSP1BUF
movf SSP1BUF,w

banksel PORTB
bsf PORTB,6
RETURN
 
End
Hi Guys,
 
I'm happy to announce you that I finnaly get it work (picture attached).
Below are the main road blocks that avoided to let the led start and show 1991 :
- Hardware issue:
                 . The max 7219 I was using was dammaged so I switched to an other one
                 . My clone logic analyser was missleqding and telling wrng informations
 
- Programm issue:
                 . return was missing at the end of the routine "RoutineveriffinSDI"
 
I thank you all for your help and hope that this topic will help somone else save time and understand how it's working
post edited by The alchmiste - 2018/08/15 15:31:52

Attached Image(s)

#54
The alchmiste
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/03/14 02:55:48
  • Location: France
  • Status: offline
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2019/12/16 04:29:39 (permalink)
0


list p=16f15344 , r=dec
 #include <p16f15344.inc>


; CONFIG1
; __config 0x3E8C
 __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_ON & _CSWEN_ON & _FCMEN_ON
; CONFIG2
; __config 0x279C
 __CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_NSLEEP & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_OFF
; CONFIG3
; __config 0xFFFF
 __CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC
; CONFIG4
; __config 0x1FE0
 __CONFIG _CONFIG4, _BBSIZE_BB64K & _BBEN_OFF & _SAFEN_ON & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
; CONFIG5
; __config 0x3FFF
 __CONFIG _CONFIG5, _CP_OFF

; _RSTOSC_HFINT1 -> permet l'activation de l'oscillateur interne a une frequence de 1Mhz soit 1 microS/osccillation
; _LVP_OFF -> permet la programmation a faible tenssion
; _CP_OFF -> Ne cache pas le code
; _WDT_OFF -> Desactive le Watch Dog


; TODO PLACE VARIABLE DEFINITIONS GO HERE

;***** VARIABLE DEFINITIONS at the bank 0 begining at adress 0x20
cblock 0X20

Binaire : 1
CompteurRotation : 1
Positionnement : 1
Verif1 : 1
Swapp : 1
Digit1 : 1
Digit2 : 1
Digit3 : 1
D11 : 1
D12 : 1
D13 : 1
D21 : 1
D22 : 1
D31 : 1
D32 : 1
D33 : 1
 

registre_Démarrage : 1
Donnée_Démmarrage : 1
Donnée_Fin : 1

registre_Parametrage : 1
Donnée_ParametrageBCD : 1

registre_Intensite : 1
Donnée_Intensite : 1

registre_nbrDigit : 1
Donnée_nbrDigit : 1

registre_Test : 1
Donnée_Test : 1

registre_Digit : 1
Donnée_Digit : 1

registre : 1
donnee : 1
 
tipe : 1
mine : 1
quantite : 1
codee : 1

endc
;*******************************************************************************
; Reset Vector
;*******************************************************************************

org 00H ; processor reset vector
goto START ; go to beginning of program

; TODO INSERT ISR HERE

;*******************************************************************************
; MAIN PROGRAM
;*******************************************************************************


START

; Initialisaton des variables

 
banksel mine
movlw 158
movwf mine
 
banksel quantite
movlw 10
movwf quantite
 
banksel codee
movlw 120
movwf codee

banksel registre_Démarrage
movlw 0x0c
movwf registre_Démarrage
 
banksel Donnée_Démmarrage
movlw 0x03
movwf Donnée_Démmarrage

banksel registre_Parametrage
movlw 0x09
movwf registre_Parametrage

banksel Donnée_ParametrageBCD
movlw 0x00
movwf Donnée_ParametrageBCD

 
banksel registre_Intensite
movlw 0x0A
movwf registre_Intensite
 
banksel Donnée_Intensite
movlw 0x07
movwf Donnée_Intensite

 
banksel registre_nbrDigit
movlw 0x0B
movwf registre_nbrDigit
 
banksel Donnée_nbrDigit
movlw 0x07
movwf Donnée_nbrDigit

banksel registre_Test
movlw 0x0F
movwf registre_Test

banksel Donnée_Test
movlw 0x01
movwf Donnée_Test



 
; Debut du programme envoie du mine, quantité ou codee sur 7 segment
Demarrage
Banksel tipe
BTFSS tipe,0 ; Pour le mine
Goto B1
BTFSS tipe,1 ; Pour les quantités
Goto B2
BTFSS tipe,2 ; Pour le codee
Goto B3
sleep

 
          ; Le code BCD
init
   
 clrf CompteurRotation
 clrf Positionnement
 clrf Verif1
 clrf Swapp
 clrf Digit1
 clrf Digit2
 clrf Digit3
 
; Ici la routine de converssion BCD

 BoucleBinaire
 
 Banksel STATUS
 BCF STATUS,C
 Banksel Binaire
 RLF Binaire
 Banksel CompteurRotation
 BTFSC CompteurRotation,3
 Goto fin
 INCF CompteurRotation
 BTFSC CompteurRotation,3
 BSF Positionnement,2
 Banksel CompteurRotation
 BTFSC CompteurRotation,2
 BSF Positionnement,1
 Banksel STATUS
 BTFSC STATUS,C
 Goto D1ajoute1
 Goto D1ajoute0
 
 Converssion
 
 Banksel Positionnement
 BTFSC Positionnement,1
 Goto ActualiserD2
 Goto ActualiserD1
 
 
;**********************************************************************
; Rotaton Digit 1 *
;**********************************************************************
 
D1ajoute1
 Banksel STATUS
 BCF STATUS,C
 Banksel Digit1
 RLF Digit1
 BSF Digit1,0
 Banksel STATUS
 BTFSC STATUS,C
 Goto D3ajoute1
 Goto D3ajoute0
 
D1ajoute0
 Banksel STATUS
 BCF STATUS,C
 Banksel Digit1
 RLF Digit1
 BCF Digit1,0
 Banksel STATUS
 BTFSC STATUS,C
 Goto D3ajoute1
 Goto D3ajoute0
 
;**********************************************************************
; Rotaton Digit 3 *
;**********************************************************************
 
 D3ajoute1
 Banksel STATUS
 BCF STATUS,C
 Banksel Digit3
 RLF Digit3
 BSF Digit3,0
 Goto D2Ajustement
 
 D3ajoute0
 Banksel STATUS
 BCF STATUS,C
 Banksel Digit3
 RLF Digit3
 BCF Digit3,0
 Goto D2Ajustement
 
;**********************************************************************
; Isolation Digit 2 *
;**********************************************************************
 
D2Ajustement
 Banksel Digit1
 MOVF Digit1,w
 Banksel Swapp
 MOVWF Swapp
 SWAPF Swapp
 MOVLW 0x0F
 ANDWF Swapp
 MOVF Swapp,w
 Banksel Digit2
 MOVWF Digit2
 Goto Converssion
 
;**********************************************************************
; Equlibrage du Digit 1 *
;**********************************************************************
 
ActualiserD1
 Banksel Digit1
 MOVF Digit1,w
 Banksel Verif1
 CLRF Verif1
 MOVWF Verif1
 MOVLW 0x0F
 ANDWF Verif1
 MOVF Verif1,w
 Banksel STATUS
 BCF STATUS,C
 SUBLW 0x04
 Banksel STATUS
 BTFSS STATUS,C
 Goto Completer1
 Goto BoucleBinaire
 
Completer1
 BTFSC CompteurRotation,3
 Goto BoucleBinaire
 MOVLW 0x03
 Banksel Digit1
 ADDWF Digit1
 BSF Positionnement,1
 Goto BoucleBinaire
 
 
;**********************************************************************
; Equlibrage du Digit 2 *
;**********************************************************************
 
ActualiserD2
 Banksel Digit2
 MOVF Digit2,w
 Banksel STATUS
 BCF STATUS,C
 SUBLW 0x04
 Banksel STATUS
 BTFSS STATUS,C
 Goto Completer2
 Goto ActualiserD1
 
 
Completer2
 BTFSC CompteurRotation,3
 Goto ActualiserD1
 MOVLW 0x03
 Banksel Digit2
 ADDWF Digit2
 MOVLW 0x0F
 Banksel Digit1
 ANDWF Digit1
 Banksel Digit2
 MOVF Digit2,w
 Banksel Swapp
 MOVWF Swapp
 SWAPF Swapp
 MOVFW Swapp
 Banksel Digit1
 ADDWF Digit1
 Goto ActualiserD1
 
 fin
 MOVLW 0x0F
 ANDWF Digit1
 
 BTFSC tipe,2
 Goto B3Affichage
 BTFSC tipe,1
 Goto B2Affichage
 BTFSC tipe,0
 Goto B1Affichage
   
 
B1 ; On charge le mine dans la variable Binaire de la routine BCD
 banksel mine
 MOVF mine,w
 banksel Binaire
 MOVWF Binaire
 banksel tipe
 BSF tipe,0
 Goto init
B1Affichage
 banksel Digit1
 MOVFW Digit1
 banksel D11
 MOVWF D11

 banksel Digit2
 MOVFW Digit2
 banksel D12
 MOVWF D12

 banksel Digit3
 BSF Digit3,7
 banksel Digit3
 MOVFW Digit3
 banksel D13
 MOVWF D13

 goto Demarrage
 
B2 ; On charge le mine dans la variable Binaire de la routine BCD
 banksel quantite
 MOVF quantite,w
 banksel Binaire
 MOVWF Binaire
 banksel tipe
 BSF tipe,1
 Goto init
B2Affichage

 banksel Digit1
 MOVFW Digit1
 banksel D21
 MOVWF D21
 banksel Digit2
 MOVFW Digit2
 banksel D22
 MOVWF D22
 
 goto Demarrage
 
B3 ; On charge le mine dans la variable Binaire de la routine BCD
 banksel codee
 MOVF codee
 banksel Binaire
 MOVWF Binaire
 banksel tipe
 BSF tipe,2
 Goto init
B3Affichage

 banksel Digit1
 MOVFW Digit1
 banksel D31
 MOVWF D31
 banksel Digit2
 MOVFW Digit2
 banksel D32
 MOVWF D32
 banksel Digit3
 MOVFW Digit3
 banksel D33
 MOVWF D33
 
 ; Initialisation des paramettres SPI

banksel RB4PPS
movlw 0x16 ;On associe SDO a RB4 ( les données transmises)
movwf RB4PPS

banksel RB5PPS
movlw 0x15 ;On associe SCK a RB5 (l'horloge)
movwf RB5PPS

banksel TRISB
movlw B'10001111' ;RB4 et RB5 et RB6 en sortie tout le rest en entrée
movwf TRISB

Banksel SSP1STAT ; On parametre l'horloge et l'echantillonage des données
movlw 0x40
movwf SSP1STAT

banksel SSP1CON1
movlw 0x20 ;On active le SPI
movwf SSP1CON1




banksel PORTB
clrf PORTB ;on efface les valeurs du port B


; Debut du parametrage Driver
;1
banksel registre_Démarrage
movf registre_Démarrage,w
call Registre

banksel Donnée_Démmarrage
movf Donnée_Démmarrage,w
call Donnée



;2
banksel registre_Parametrage
movf registre_Parametrage,w
call Registre

banksel Donnée_ParametrageBCD
movf Donnée_ParametrageBCD,w
call Donnée


;3
banksel registre_Intensite
movf registre_Intensite,w
call Registre

banksel Donnée_Intensite
movf Donnée_Intensite,w
call Donnée


;4
banksel registre_nbrDigit
movf registre_nbrDigit,w
call Registre

banksel Donnée_nbrDigit
movf Donnée_nbrDigit,w
call Donnée



;5
banksel registre_Test
movf registre_Test,w
call Registre

banksel Donnée_Test
movf Donnée_Test,w
call Donnée

banksel registre_Test
movf registre_Test,w
call Registre

movlw 0x00 ;fin du test
call Donnée
 
;6
banksel registre_Parametrage
movf registre_Parametrage,w
call Registre

movlw 0xFF
call Donnée
 
 MOVLW 0x00
 call Registre
 banksel D11
 MOVFW D11
 call donnee
 
 MOVLW 0x01
 call Registre
 banksel D12
 MOVFW D12
 call donnee
 
 MOVLW 0x02
 call Registre
 banksel D13
 MOVFW D13
 call donnee
 
 MOVLW 0x03
 call Registre
 banksel D21
 MOVFW D21
 call donnee
 
 MOVLW 0x04
 call Registre
 banksel D22
 MOVFW D22
 call donnee
 
 MOVLW 0x05
 call Registre
 banksel D31
 MOVFW D31
 call donnee
 
 MOVLW 0x06
 call Registre
 banksel D32
 MOVFW D32
 call donnee
 
 MOVLW 0x07
 call Registre
 banksel D33
 MOVFW D33
 call donnee
 
 SLEEP


Registre
banksel registre
movwf registre
return



Donnée
banksel donnee
movwf donnee
call RoutineveriffinSDI
return



RoutineveriffinSDI

banksel PORTB
bcf PORTB,6

banksel registre
movf registre,w
banksel SSP1BUF
movwf SSP1BUF
banksel SSP1STAT
btfss SSP1STAT,0
goto $-1
banksel SSP1BUF
movf SSP1BUF,w

banksel donnee
movf donnee,w
banksel SSP1BUF
movwf SSP1BUF
banksel SSP1STAT
btfss SSP1STAT,0
goto $-1
banksel SSP1BUF
movf SSP1BUF,w

banksel PORTB
bsf PORTB,6
RETURN

End
Hi all,
 
I'm back on this project and facing some issue with the code implemented in the pic.

I have the code in 2 main steps: 
 
1) convert a Binary code in BCD that I've done nd seems to work correctly with the simulator
2) show the Binary coded decimal on the 7 segment display
 
But after loading the code in the pic it's showing randome numers and characteres, do anyone understand where is the issue?
post edited by The alchmiste - 2019/12/16 04:36:14
#55
ric
Super Member
  • Total Posts : 27624
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Pic 16F15344 and Max7219 to drive 7 segment display in asm 2019/12/16 05:02:08 (permalink)
+1 (1)
I don't know if this causes your problem, but
banksel PORTB
bcf PORTB,6

should be
banksel LATB
bcf LATB,6

 
and similarly
banksel PORTB
bsf PORTB,6

should be
banksel LATB
bsf LATB,6

 
never ever use the BSF and BCF instructions on the PORT registers.
 
Note, STATUS is a "core register". It exists in all banks, so "BANKSEL STATUS" is pointless.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#56
Page: < 123 Showing page 3 of 3
Jump to:
© 2020 APG vNext Commercial Version 4.5