News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Positron and MAX7219 Problem

Started by DigiMan, Apr 05, 2025, 03:09 PM

Previous topic - Next topic

DigiMan

Hi friends,

I used to use proton before, now I use positron. I upload the .hex file of a code I wrote with the proton version to the device and it works fine.

When I compile the same code with POSITRON without making any changes, create a .hex file and upload it to the same device, it does not work properly.

My device has a MAX7219 display driver and my processor is 18F2620. The crystal is 20Mhz.

I am giving a part of the code below. This code should display a 3-digit number on the screen and make a sound every 1/2 second. However, the screen does not work and the sound comes sometimes.

Does anyone have a similar problem? Is there a different writing method in Positron? Are there any missing or incorrect codes? I ask for your help.

Thank you,,

DigiMan


Device = 18F2620
XTAl = 20
ALL_DIGITAL = True

Symbol SCLpin      = PORTC.2 
Symbol SDApin     = PORTC.3
Symbol SHT_DTA  = PORTC.0 
Symbol SHT_CLK  = PORTC.1 
Symbol SW2         = PORTA.0
Symbol SW1         = PORTA.1
Symbol BUTON    = PORTC.4
Symbol SES           = PORTA.4 
Symbol ALARM    = PORTB.0
Symbol EXT_SH    = PORTA.2 
Symbol EXT_LT     = PORTA.3 
Symbol EXT_DT    = PORTA.5
Symbol L1              = PORTC.5
Symbol L2              = PORTC.6
Symbol L3              = PORTC.7
Symbol L4              = PORTB.1
Symbol C1              = PORTB.2
Symbol C2              = PORTB.3
Symbol MAX_LD   = PORTB.4
Symbol C4              = PORTB.5
Symbol MAX_CK   = PORTB.6
Symbol MAX_DT   = PORTB.7

TRISA = %00000011
TRISB = %00000000
TRISC = %00011111

Input BUTON
Low BUTON
High SW1
High SW2
High SES
Low ALARM
Low L1
Low L2
Low L3
Low L4
Low C1
Low C2
Low C4
Low MAX_LD
Low MAX_CK
Low MAX_DT
dim TusDegeR as byte
dim X as byte
Dim ADDRESS as word
dim DATAREG As word
Clear
delayms 200

TusOkU:       
    DelayMS 500
    Low SES : DelayMS 50 : High SES   
    ADDRESS = 1 : DATAREG = 15 : GoSub MAXYAZ
    ADDRESS = 2 : DATAREG = 28 : GoSub MAXYAZ
    ADDRESS = 3 : DATAREG = 91 : GoSub MAXYAZ
    ADDRESS = 4 : DATAREG = 0 : GoSub MAXYAZ   
   
    Low BUTON
    DelayMS 10                 
    TusDeger = RCIn BUTON, Low       
   
    ADDRESS = 5 : X = Dig TusDeger, 2 : GoSub ZAMAN : GoSub MAXYAZ
    ADDRESS = 6 : X = Dig TusDeger, 1 : GoSub ZAMAN : GoSub MAXYAZ
    ADDRESS = 7 : X = Dig TusDeger, 0 : GoSub ZAMAN : GoSub MAXYAZ
    gosub SetmaX   
GoTo Tusoku



ZAMAN:
   DATAREG = LookUpl X,[126,48,109,121,51,91,95,112,127,123]
   return   

MAXYAZ:
   SHOut MAX_DT,MAX_CK,msbfirst,[ADDRESS,DATAREG]
   high max_ld
   delayus 2
   low max_ld
   return

SetmaX:
   ADDRESS = $09 : DATAREG = $00 : GoSub MAXYAZ   'Decode register          00= kodsuz   /  FF= kodlu
   ADDRESS = $0A : DATAREG = $09 : GoSub MAXYAZ   'Intensity register.       00= min      /  0F= max
   ADDRESS = $0B : DATAREG = $07 : GoSub MAXYAZ   'Scan-limit register.     00= birinci  /  07= hepsi
   ADDRESS = $0C : DATAREG = $01 : GoSub MAXYAZ   'On/Off Register.         00= disp off /  01= disp on
   ADDRESS = $0F : DATAREG = $00 : GoSub MAXYAZ   'Test mode register     00= normal   /  01= test-8
   return

Pepe

demo proteus with positron

DigiMan

Hi Pepe,
I will test it and tell you the result.


Thanks