Hi all
I did a sofware for an electric motorcyle with Mikrobasic.
It was OK except ... it did strange things now, just because soft is more big than before.
For explanation: soft works (speed display, current, cell voltage, time...) but, if I add this in main :
if Condition then
ProcedureXY
end if
Soft seems not to be correct anumore, even if
condition false !
(in fact I tried to replace "if" by "goto" to be sure conition was not ok and it does the same thing ! )
So I decided to try translation to Proton, if it's not too hard

I think the longest problem is to configure correctly PIC (in fact it's a PIC4553, not 4550 but they have same use)
Is someone able to traduce folowing (mikrobasic) code for me, that's would be great.
program Ysr18
' (=Ysr17 -> suppression du cycle analyst et des cell-log)
'----------------------------------------------------------------
'Configuration:
' Regler le MCU clock a 48Mhz ! (96Mhz/2)
'CPU pre-scaler -> divisé par 5 pour obtenir 20/5=4 Mhz qui devient ensuite le 48Mhz de façon interne
'CPU Systemclock Postscaler OSC1/OSC2 Src:/1 96Mhz PLL Src:/2
'Full USB Clock source: Clock src from OSC1/OSC2
'Oscillator: HSHS+PLL, USB+HS
'Fail Safe Clock: Disable
'Internal/Extarnal switch: Disabled
'Power up timer: Disabled
'Brown Out Detect: Enabled in hardware, SBOREN disabled
'Brown out voltage: 2.0V
'USB Voltage: Disabled
'Watchdog Timer: Disabled-Controled by SWDTEN bit
'Watchdog Poscaler: 1:32768
'Port B A/D Enabled: PORTB configured as digital I/O on RESET
'Master Clear Enable: MCLR enabled, RE3 Disabled
'Stack overfow Reset: Enabled
'Low voltage Program: Disabled
'Boot Block Size Select 1KW
'Reste: Disabled
'----------------------------------------------------------------
'entrées
symbol TensionCell = PORTA.0
symbol GlobalCurrent = PORTA.1
symbol GlobalVoltage = PORTA.2
symbol ChargeurIn = PORTA.4
symbol SpeedPulse = PORTB.0
symbol RFIDin = PORTB.1
symbol BrakeIn = PORTC.4
symbol InMove = PORTC.5
symbol NeSertPlus = PORTC.7
symbol InNoir = PORTD.0
symbol InRouge = PORTD.1
symbol PhareIn = PORTD.2
symbol ClignotantIn = PORTD.3
symbol InJaune = PORTE.1
'sorties
symbol RsLcd = PORTA.3
symbol EnLcd = PORTA.5
symbol SelectAudio = PORTB.2
symbol ADCsel1B = PORTB.3 '=D6 lcd
symbol ADCsel2B = PORTB.6 '=D4 lcd
symbol ADCsel2A = PORTB.7 '=D5 lcd
symbol PowerRL2 = PORTC.0
symbol ADCsel1A = PORTC.1 '=D7 lcd
symbol LedClavier = PORTC.2
symbol SortieTx = PORTC.6
symbol PowerSyst = PORTD.4
symbol Buzzer = PORTD.5
symbol AlarmeOut = PORTD.6
symbol WPEeprom = PORTD.7
symbol BrakeOut = PORTE.0
symbol ForcePower = PORTE.2
'timer
Symbol TMR0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
Symbol TMR0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
Symbol TMR1IE = PIE1.0 ' TMR1 Overflow Interrupt Enable
Symbol TMR1IF = PIR1.0 ' TMR1 Overflow Interrupt Flag
Symbol TMR2IE = PIE1.1 ' TMR2 to PR2 Match Interrupt Enable
Symbol TMR2IF = PIR1.1 ' TMR2 to PR2 Match Interrupt Flag
'constantes
const DelaiAlarme = 254
const DelaiPosition =500
const DelaiTresTresCourt = 90
const DelaiCourt = 180
const PositionPremierBitAnalyst=29
const AdresseDistanceTotale =12 '(et 13,14,15)
const AdresseRapportVitesse =16 '(et 17) rapport de conversion Vitesse (6.25 au départ)
const AdresseRapportTension50V =18 '(et 19) rapport de conversion Tension (52 au départ)
const AdresseRapportTension3V7 =20 '(et 21) rapport de conversion Tension (4.85 au départ)
const AdresseRapportCourant =22 '(et 23) rapport de conversion courant (11.6 au départ)
const AdressePointZeroCourant = 24 '(et 25) point de référence négatif/positif (1182 au départ)
const AdresseAmperesHeure =26 '(et 27)
const AdresseTempsCharge =28 '(et 29)
const AdresseCourbeCharge1 =200 '(2040 points possibles, enregistrés en word)
const AdresseCourbeCharge2 =2300 '(2040 points possibles, enregistrés en word)
const AdresseCourbeDecharge1 =4300 '(2040 points possibles, enregistrés en word)
const AdresseCourbeDecharge2 =6400 '(2040 points possibles, enregistrés en word)
const Decalage=10
'variables
dim Soft_I2C_Scl as sbit at RB5_bit
dim Soft_I2C_Sda as sbit at RB4_bit
dim Soft_I2C_Scl_Direction as sbit at TRISB5_bit 'définit le clock I2C
dim Soft_I2C_Sda_Direction as sbit at TRISB4_bit 'définit le data I2C
' Lcd module connections
dim LCD_RS as sbit at RA3_bit
LCD_EN as sbit at RA5_bit
LCD_D4 as sbit at RB6_bit
LCD_D5 as sbit at RB7_bit
LCD_D6 as sbit at RB3_bit
LCD_D7 as sbit at RC1_bit
dim LCD_RS_Direction as sbit at TRISA3_bit
LCD_EN_Direction as sbit at TRISA5_bit
LCD_D4_Direction as sbit at TRISB6_bit
LCD_D5_Direction as sbit at TRISB7_bit
LCD_D6_Direction as sbit at TRISB3_bit
LCD_D7_Direction as sbit at TRISC1_bit
.........
...........
............
'DEBUT DU PROGRAMME PRINCIPAL
'note: si la TensionGlobale est nulle (au lieu de 53V) le système est en mode démo
main:
TRISA = %00010111 ' PORT A (1=entrée, 0=sortie)
TRISB = %00000011 ' PORT B
TRISC = %10110000 ' PORT C
TRISD = %00001111 ' PORT D
TRISE = %00000010 ' PORT E
PortA=%00110000 ' on met le LCD enable au niveau haut car actif front descendant
PortB=%00000000
PortC=%00100000
PortD=%10000000 'on met WP au Niveau haut pour interdire l'écriture sur l'Eeprom
PortE=%00000000
UART1_Init(9600)
Delay_Ms(250) ' attente de stabilisation
'------------------------------------
' réglage du timer
'configuration de l'interrupt du timer2
'T2CON = %01111111 ' Set T2CON.2
'TMR2IF=0
'TMR2IE=0
'TMR2=0
'PR2=190'5
CMCON = 0X07 ' Turn off all comparators.
INTCON=0 'pas d'interruption
ADCON0 = 0x01 ' choix canal convertisseur A/D (ici=1)
ADCON1 = 0X00 ' Reset registre A/D 1.
ADCON1 = %1100 ' activation AN2,AN1,AN0
soft_I2C_init()
Lcd_Init()
Lcd_Cmd(_LCD_CURSOR_OFF)
INTCON.INT0IE = 1 ' autorise INTO (=compteur vitesse)
INTCON.INT0IF = 0 ' flag INT0 à zéro
INTCON3.INT1IE = 1 ' autorise interruption INT1 (RFID)
INTCON3.INT1IF = 0 ' flag INT1 à zéro
INTCON3.INT1IP= 0 ' priorité basse
INTCON.INTEDG0=1
INTCON2.INTEDG1=1 ' selectionne front montant
INTCON.GIE = 1 ' autorise interruptions
UCON.USBEN = 0 'désactive l'USB sur port C4 et C5
UCFG.UTRDIS = 1 'désactive le transmetteur USB sur port C4 et C5
..........
...............
.................
Sorry, it's in french so, perhaps, not very clear.
Thanks for help