Menu

Error on word variable

jackjames
2020-08-01
2020-08-01
  • jackjames

    jackjames - 2020-08-01

    Hello,
    I find an error during the compilation of which I can not understand its origin.
    It is a mathematical operation on a word variable.
    I attach a test list that generates the error and a screen with the generated error.

            #Option Explicit
    '       -
    '       -
            #Chip 16F1847, 32
            #Config OSC = INT, MCLR_OFF
    
    '       -
    '       Timers
            #Define MAXTIMERS       8
            #Define TMR_ORASTART    Timer (0)
            #Define TMR_MINUTOSTART Timer (1)
            #Define TMR_ORASTOP     Timer (2)
            #Define TMR_MINUTOSTOP  Timer (3)
            #Define TMR_GIORNI      Timer (4)
            #Define TMR_MASKRELE    Timer (5)
            #Define TMR_ATTIVO      Timer (6)
            #Define TMR_ABILITATO   Timer (7)
    '       -
    '       Per la gestione dell'orario dei timers
            Dim wStart (MAXTIMERS)  As Word
            Dim wStopp (MAXTIMERS)  As Word
            Dim wIncre (MAXTIMERS)  As Word
            Dim Timer (8)           As Byte
    
    '
    
    main:
            CalcolaValoriTimer (1)
            End
    
    '       ========================================================================
    '       Calcola i valori con l'orario per la programmazione di tutti i timers
    '       ------------------------------------------------------------------------
    Sub CalcolaValoriTimer (In NTimer As Byte)
    '       LeggiTimer NTimer                                                 ' Read from EEProm
            wStart (NTimer -1) = [Word] TMR_ORASTART * 60 + TMR_MINUTOSTART   ' Ora start
            wStopp (NTimer -1) = [Word] TMR_ORASTOP * 60 + TMR_MINUTOSTOP     ' Ora Stop
            '-
            If wStart (NTimer -1) > wStopp (NTimer -1) Then
               wIncre (NTimer -1) = wStopp
               wStopp (NTimer -1) = wStopp (NTimer -1) + 1440
            Else
               wIncre (NTimer -1) = 0
            End If
    End Sub
    '
    
     
  • jackjames

    jackjames - 2020-08-01

    Problem solved !
    After two hours of repricing I realized that I had not put the index on the wstop variable.
    This is the advancing old age ...

     
    • Anobium

      Anobium - 2020-08-01

      :-)

      wIncre (NTimer -1) = wStopp where wStopp needed an array index.

      Easy to do, hard to debug.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.