Menu

mega328p pullup

Help
2017-06-26
2017-07-18
<< < 1 2 (Page 2 of 2)
  • stan cartwright

    stan cartwright - 2017-07-02

    Thanks for the reply. However there is still the max freqency of 65535 problem. Here is your code modified for different display and a video.https://youtu.be/g0k_cdQhXZs
    I'm trying counting with 1000 every 1ms interrupts and adding the timer1 overflows every 1ms clearing timer1 each time.

     
  • stan cartwright

    stan cartwright - 2017-07-02

    Running a timer0 1ms int and timer1 count overflow is interesting. I either get alternate 65535 or 1Hz or no display frequency and slow mo printing of just the 1 time print "Frequency=". lots of fun

     
  • stan cartwright

    stan cartwright - 2017-07-03

    I tried using your code with 18f25k22 but the hardware spi uses portC.0. Is that the input pin for ext timer1 count? ie T1CKI

     
  • stan cartwright

    stan cartwright - 2017-07-04

    This code counts timer1 overflows in every ms and adds them up 1000 times. There's still the over flow at 65535 Hz and 60KHz reads around 59590 every second. Don't know why it misses pulses.
    There's a line commented out that stops it printing frequency. So the display is stopping timer0?.
    GLCDDrawString (0,64,str(number_of_timer1_overflows),ILI9341_white)
    So the display is stopping timer0?.

    #chip mega328p, 16 ;freqency meter using input on portD.5
    #option explicit
    #include <glcd.h>
    ;
    #define GLCD_TYPE GLCD_TYPE_ILI9341
    #define GLCD_DC   portb.2 ;    DIGITAL_10         'HW Data command line DC
    #define GLCD_CS   portd.7 ;    DIGITAL_7          ' Chip select line CS
    #define GLCD_RESET   portd.4 ;      DIGITAL_4         ' Reset line Tie high..not needed
    #define GLCD_DO   portb.3 ;   DIGITAL 11          'HW Data out | MOSI SDI
    #define GLCD_SCK   portb.5 ;   DIGITAL_13          'HW Clock Line SCK
    #define ILI9341_HardwareSPI    ' remove/comment out if you want to use software SPI.
    #define GLCD_EXTENDEDFONTSET1
    GLCDfntDefaultsize = 2
    GLCDRotate (landscape)
    GLCDCLS ILI9341_BLACK
    ;
    dim number_of_timer1_overflows , number_of_1ms_interrupts , temp_timer1 as word
    number_of_1ms_interrupts = 0
    Dim Frequency as Long
    ;
    On Interrupt Timer0Overflow Call every1ms
    InitTimer0 Osc, PS_0_64
    StartTimer 0
    ;
    Inittimer1 (EXT, PRE0_1)
    On interrupt Timer1Overflow Call Counter1Overflow
    ;
    Cleartimer 1
    number_of_timer1_overflows = 0
    Starttimer 1
    ;
    GLCDDrawString (0,0,"Frequency =",ILI9341_YELLOW)
    do
    ;GLCDDrawString (0,64,str(number_of_timer1_overflows),ILI9341_white);with this line it never prints freqency?
    ;if 1000 1ms interrupts occurred
    if number_of_1ms_interrupts = 1000 then
      stoptimer 1
      Frequency = Frequency * 65536 + timer1
      GLCDDrawString (158,0,str(Frequency)+" Hz   ",ILI9341_white)
      clearTimer 1
      number_of_1ms_interrupts = 0
      StartTimer 1
    end if
    Loop
    ;
    sub Counter1Overflow
      number_of_timer1_overflows = number_of_timer1_overflows + 1
    End Sub
    ;
    sub every1ms
      Settimer 0, 6 '1.002ms
      stoptimer 1
      temp_timer1 = timer1 ;store timer 1 value
      number_of_1ms_interrupts = number_of_1ms_interrupts + 1
      Frequency = Frequency + number_of_timer1_overflows ;total counter1 overflows
      number_of_timer1_overflows = 0 ;reset number_of_timer1_overflows for next 1ms
      Settimer 1, temp_timer1 ;restore timer 1 value
      StartTimer 1
    end sub
    
     

    Last edit: stan cartwright 2017-07-04
    • Anobium

      Anobium - 2017-07-04

      We need the full code. Please attach. Why ? I don't know if you are using hardware twi or any other accessories.

       
  • stan cartwright

    stan cartwright - 2017-07-04

    I edited my previous post.It never gets past -- if number_of_1ms_interrupts = 1000 then, so timer0 interrupt is not increasing the var number_of_1ms_interrupts. I searched the glcd include for int.
    From the data sheet I don't know if the hardware spi is using the timers.

     
    • Anobium

      Anobium - 2017-07-04

      OK. I need the source, the LST file and the ASM file. I cannot recreate your code and I am aware that you have some updates to your installation so we do need to see these files to understand.

      To my knowledge there are no interrupts in the GLCD code, but, the ASM will tell me a lot more.

       
  • stan cartwright

    stan cartwright - 2017-07-04

    Files with error line.

     
    • Anobium

      Anobium - 2017-07-04

      This was revealing to me. Probably a problem of my making. You version of the compiler was either issued by me to test something or you could have built this yourself - but, we need to get you on a release the majority of the dev team are using so they can support you. To my knowledge they are not on the patch release you are using.

      So, no worry. We just need to get you on a release that is supported and others have the same build.

       
      • Anobium

        Anobium - 2017-07-04

        I just checked the release logs for the compiler. We need anyone helping you, with this, on v.0.97.02 RC 7 or greater.

        @Stan. We need you on the same build also - otherwise the mismatch in release may cause issues.

         
  • stan cartwright

    stan cartwright - 2017-07-18

    The overflow after 65535 was due to me using glcdprint (x,y,str(longvar),colour). I should have used str32(varlong).

     
    • Anobium

      Anobium - 2017-07-18

      Oh dear. Oh dear.

       
  • stan cartwright

    stan cartwright - 2017-07-18

    Indeed. No one else would have made that mistake from it being mentioned once in a help example :)
    The answer is out there...somewhere.....not obvious. Bora Da :)
    ps my sig gen goes tits above 800KHz...from a mate's duff box it seems.
    and I want one like you got for £30 odd quid init ...serious

     

    Last edit: stan cartwright 2017-07-18
    • Anobium

      Anobium - 2017-07-18

      STR() - The Str function will convert a number into a string. number can be any byte or word variable, or a fixed number between 0 and 65535 inclusive.

      Do you think we should update the Help? If yes. Send me some words and I can add to the Help. Please indicate which section etc.

      Thank you.

       
  • stan cartwright

    stan cartwright - 2017-07-18

    time lag. I made a mistake others could...with a stretch
    Don't assume anything. GCB is different to other basic. Most problems are me not reading the instructions.
    It's basic jim but not as you knew it

     

    Last edit: stan cartwright 2017-07-18
  • Anobium

    Anobium - 2017-07-18
    time lag. I made a mistake others could...with a stretch
    

    Yes, others may have the same syntax error. Send through all Help file updates please to assist others on the same journey.

     
  • stan cartwright

    stan cartwright - 2017-07-19

    Anobium. Joe User likes that and what is the equivelent of floats.. in less than 10 words, You don't win anything though :(

     
  • Anobium

    Anobium - 2017-07-19

    I have updated the Help. Published on the web already. The next release will include updates to the IDE Help, improved IDE helper and more examples in the Help with respect to STR() and VAL().

    If you want the latest CHM get it here: http://gcbasic.sourceforge.net/help/output/ There are many formats - remember if you download the CHM to your computer you will have to UNBLOCK the file. See http://digital.ni.com/public.nsf/allkb/B59D2B24D624B823862575FC0056F3D0 for more information.

     
  • stan cartwright

    stan cartwright - 2017-07-19

    I'll use the online help from now. Scaleing pi is loads of fun but exceeded my attention span. In school trig was as useful as learning Welsh. It was Welsh or latin and they didn't write prescriptions in Welsh then and I didn't want to know how high a flagpole was.

     
<< < 1 2 (Page 2 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.