Menu

Blocking problem with TIMER1

Gigi
2023-11-19
2023-11-21
1 2 > >> (Page 1 of 2)
  • Gigi

    Gigi - 2023-11-19

    I have a long time to understand why TIMER1 didn't work, the start function completely blocked TIMER1!! How come?

     
  • Anobium

    Anobium - 2023-11-19

    Sorry, I do not understand the question.
    Can you help me understand what is happening or not happening?

     
  • Anobium

    Anobium - 2023-11-19

    Sorry, I do not understand the question.
    Can you help me understand what is happening or not happening?

     
  • Gigi

    Gigi - 2023-11-19

    If you try the attached code, on the simulator, TIMER1 does not work and remains blocked. If you eliminate the start function call everything goes perfectly, it seems to be timer1=0 inside the function that is causing the problems.

     
  • Gigi

    Gigi - 2023-11-19

    In the simulator if you check the TMR1L and TMR1H registers you will see that the counting does not take place and they remain stationary.

     
    • Anobium

      Anobium - 2023-11-19

      Which simulator?

       
  • Gigi

    Gigi - 2023-11-19

    The usual RealPicSimulator, I only tested this code to better understand the problem it created for me on another program.

     
  • Anobium

    Anobium - 2023-11-19

    Look ok to me. Loaded the HEX and set a break at address 0x112, and. it breaks as expected with addresses 0x15-0x14 set to 0x0002 ( as time1 with have incremented during the interrupted. This called interrupt latency and is expected).

    So, I do not see the issue.

     
  • Gigi

    Gigi - 2023-11-19

    In my opinion it's not an Interrupt problem it's just that TIMER1 remains stopped!
    Try this and see the simple changes and TIMER1 register

     
    • Anobium

      Anobium - 2023-11-19

      Tried it in Real Sim. Addresses for Timer1 ( 14 and 15 ) are incrementing. With a Break at line 0x114 the program reaches it as expected. So, Timer1 is incrementing.

      And, walking the program using {F7} shows Timer1 incrementing.

       

      Last edit: Anobium 2023-11-19
  • Gigi

    Gigi - 2023-11-19

    In fact, in the second test everything works, in the first it doesn't, The problem is inside the "TIMER1=0" function which gives some kind of problem

     
  • Anobium

    Anobium - 2023-11-19

    Sorry, with the first GCB I am getting the timer increment.

    Post the first line of your ASM. I want to see versions etc.

     
  • Gigi

    Gigi - 2023-11-19

    ;Program compiled by GCBASIC (1.01.00 2023-11-15 (Windows 64 bit) : Build 1300) for Microchip MPASM/MPLAB-X Assembler using FreeBASIC 1.07.1/2023-11-15 CRC29

     
  • Anobium

    Anobium - 2023-11-19

    Thank you. We are on the same build. So, that rules out that issue.

    The emulator - I am seeing the Timer1 registers increment. So, If you wish I can try on real hardware on Tuesday. But, I expect this to work.

    Can you video your issue?

     
  • Gigi

    Gigi - 2023-11-19

    I thank you for being interested quickly, you are a truly very helpful person. I just wanted to point out this anomaly, I solved it by simply avoiding the function for timer1, so see if you want to find out more, I'm available if necessary.
    By the end of the year I will also leave a donation to support GCB

     
    • Anobium

      Anobium - 2023-11-19

      Please send me your Sim project file and the hex. I want to resolve for you.


      Thank you for your donation. Funds are needed. Not making much progress, last year was a lot easy to raise the funds.

       
  • Gigi

    Gigi - 2023-11-19

    Tomorrow I'll post a new program that highlights the timer block.
    Thank you

     
  • Gigi

    Gigi - 2023-11-20

    Try this code, it doesn't work TIMER1 stopped gpio.0 does not change****

     
  • Gigi

    Gigi - 2023-11-20

    Sorry and the opposite this one doesn't work, the previous one works

     
    • Anobium

      Anobium - 2023-11-20

      The program below works in my copy of Real Simulator v1.3.0.0

      I get a flashing LED.

      This is code - is the the correct code?

      '''A demonstration program for GCGB and GCB.
      '''--------------------------------------------------------------------------------------------------------------------------------
      
      #chip 12F675,4      'Velocit� in Mhz oscillatore interno
      #config INTRC_OSC_NOCLKOUT, WDT_OFF, MCLR_Off, BOD_on, PWRT_on
      #option explicit  'dichiarazione variabile obbligatoria
      
      on interrupt Timer1Overflow call int_tmr1
      
      ' --- Test STORE EEPROM
      'EEprom EPmem 15
      '    11,22,33
      'end eeprom
      
      dim sec as Byte
      dir gpio.0 out
      
      ' -- Impostazioni TIMER1
      InitTimer1 Osc, PS1_8     '  16_bit interrupt Ticket 250 mS
      TMR1IF = 0
      inton                       ' Enable ALL interrupts
      StartTimer 1                'start timer1
      start
      'timer1=0:sec=0
      
      do
      
      loop
      
      Function start
          timer1=0
          sec=0
      end Function
      sub int_tmr1
          sec ++
          gpio.0 = ! gpio.0
          TMR1IF = 0
      end sub
      

      I recommend you compare the ASM, try the project with my HEX.

       
  • Gigi

    Gigi - 2023-11-20

    Your HEX works mine NOT!!!

     
    • Anobium

      Anobium - 2023-11-20

      Crikey. I will investigate.

      I am travelling for this morning. Check back this p.m.

       
  • Anobium

    Anobium - 2023-11-20

    The issue is directly related to calling a Function ( rather than a Sub ) and not assigning the result to a variable.

    Try putting a NOP after start, or put a NOP after start, try compiling with "BASIC code as comments", or, assign the Function dummayvar=start (create the variable dummyvar). Any of these will generate the correct ASM.

    My difference to you...I always compile with "BASIC code as comments",

    The compiler should not do what it is doing.

    Incorrect ASM.

    SysDoLoop_S1                - this is the DO
        call    FN_START           -  oh dear... wrong place!!!
        goto    SysDoLoop_S1      -  this is the LOOP
    SysDoLoop_E1                - this is the END Loop label
    

    should be

        call    FN_START
    SysDoLoop_S1
        goto    SysDoLoop_S1
    SysDoLoop_E1
    

    I will change the compiler to resolve this bug.

     
  • Gigi

    Gigi - 2023-11-20

    What does it mean "BASIC code as comments", can you give me an example

     
  • Gigi

    Gigi - 2023-11-20

    I tried this and it works

    ' -- Impostazioni TIMER1
    InitTimer1 Osc, PS1_8 ' 16_bit interrupt Ticket 250 mS
    TMR1IF = 0
    inton ' Enable ALL interrupts
    StartTimer 1 'start timer1

    start
    nop
    'timer1=0:sec=0

     
1 2 > >> (Page 1 of 2)

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.