Menu

Counting input pulse

Help
JB
2024-03-20
2024-04-04
  • JB

    JB - 2024-03-20

    Hi everyone,
    I'm searching for an equivalent command of the Picaxe "COUNT pin, period, wordvariable"
    I looked at the "Pulsein" of GCStudio but it count the duration of the "High" state of a pulse and not counting
    how many low to high pulse during a period.

    Thank's for any tip.

     
    • Anobium

      Anobium - 2024-03-21
       
    • Willem

      Willem - 2024-04-04

      Hi JB,
      Did you find an answer to the counting of pulses problem ? I can be mistaken but it looks to me that GCB can only count duration of a pulse, it looks to me you are also looking for a count of pulses in a time frame ?
      Willem

       
  • JB

    JB - 2024-03-20

    Also how to setup a ATTINY10 external clock source to use a 16MHz crystal.
    Tk's

     
  • JB

    JB - 2024-03-20

    I found from the ASM file the register line:
    ldi SysValueCopy,0 ; <-- if I'm right 0=internal 8Mhz and 2=external 16MHz x-tall
    out CLKMSR,SysValueCopy

    now I edited the line as is :  ldi  SysValueCopy,2
    
    save the file, then generate the HEX file
    
    get a Synwrite message asking if I want to reread it from disk, I click OK
    
    now do I click make HEX & FLASH and the changes will be loaded to the chip?
    
     
    • Anobium

      Anobium - 2024-03-21

      Maybe we change the compiler library to support the change of frequency so you do not have to edit the ASM.

      The intent is have the compiler correct set frequency, however, for the some of AVRs this is not the case. Either because Hugh, now me, have no implemented or no one has asked or the Fuses set the frequency.

      If it a very simple task to change the compiler to handle the frequency.

      So, the intent is not to edit the ASM as you will need a load more tools, and, each time you compile it will revert the ASM.

      I recommend resolving this rather than change the ASM.

       
  • JB

    JB - 2024-03-21

    That will be great to be able to setup between internal and external clock.
    Thank;s for the tip.

     
    • Anobium

      Anobium - 2024-03-21

      I will add to the Backlog... meanwhile add this.

      #startup myInit, 90
      
      
      '''' lots of code
      
      End
      
      
      sub myInit
      
          CLKMSR = 0b10   // eauate to external OSC
      
      End Sub
      

      And, add this to your program.


      I got a warning that 16mHz was too fast for chip. Is this true? What does the datasheet state ?

       
  • JB

    JB - 2024-03-21

    Hello,
    from the datasheet it's mention the external clock variation must be < 2% to be accurate, otherwise it can lead to unpredictable behavior.
    Best way to it's to try.

     
    • Anobium

      Anobium - 2024-03-21

      My question was about the max mHz of the chip. In the GCBASIC chip database it shows as 12mHz, so, your 16mHz will issue a warning.

      It would be good to understand the max mHz.

       
  • JB

    JB - 2024-03-21

    You are 100% correct
    I took from the table 7-1.

     
  • Anobium

    Anobium - 2024-03-21

    Ok. Max is 12mHz.

    What is meant by 16mHz in 7.2 ?

     
  • JB

    JB - 2024-03-21

    Good question,
    didn't find any documentation except from Atmel / Microchips.

     
    • Anobium

      Anobium - 2024-03-21

      I did search on the web and Microchip website, and, nothing on the Microchip forum ( all nine post regarding the ATTINY10!) I did not find any insights.

      I have opened a ticket with Microchip to get clarification. Is the 12mHz the error ? or, 16mHz?


       
  • JB

    JB - 2024-03-21

    Good help, tk's
    my assumption is the datasheet refer to ( 0-16mHz) this could mean an external clock source from 0 to 16mHz max, and the chip will manage the speed grade as shown on page 2.

     
    • Anobium

      Anobium - 2024-03-21

      I don't think that assumption is safe.

      I would be guessing hence I opened the ticket.

       
  • JB

    JB - 2024-03-22

    It's good to know, thank's

     

Log in to post a comment.