• AVR Freaks

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 : 9920
  • 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 : 32
  • 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 : 32
  • 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 : 32
  • 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 : 32
  • 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 : 6801
  • 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 : 32
  • 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 : 32
  • 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 : 32
  • 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 : 32
  • 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
Page: < 123 Showing page 3 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5