Proton BASIC Compiler - Number of Cycles


  • PicŪ Basic


  • Number of Cycles

    If you want to know the number of cycles it takes to perform a task on a PICŪ the following gives an example...

    INCLUDE "PROTON_G20.INT" 'Proton 20MHz Graphics LCD
    DIM TIMER1 AS TMR1L.WORD 'See help file
    DIM X AS FLOAT
    DIM Y AS FLOAT 'Dim some FLOATS
    DIM Z AS FLOAT

    DELAYMS 500 'Give PICŪ a chance to wake-up

    CLS 'Clear the GLCD

    X = 1234.321 'Load 1234.321 into X FLOAT
    Y = 3.33 'Load 3.33 into Y FLOAT

    CLEAR TIMER1 'Clear TIMER1
    '#########################
    T1CON = %00000001 'Enable the Timer

    Z = X * Y 'Code to calculate

    T1CON = %00000000 'Stop the Timer
    '#########################

    PRINT AT 0,0,"CYCLES ",DEC TIMER1 'Print out the number of Cycles
    PRINT AT 2,0,"ANSWER ",DEC Z 'Print out Answer
    END
    contributed by RON
  • Recent Activity

    david-48000

    Valid time in NMEA sentance

    Thread Starter: SimonJA

    Is there any way to know that a GPS nmea sentence has the correct time? I use a module to keep a pic rtc accurate but have noticed that when...

    david Yesterday, 20:40 Go to last post
    towlerg-21522

    I'm over the moon with joy. :-)

    Thread Starter: Les

    I just had to show you this, because I am over the moon with it. LOL I've just about finished procedures on the Proton 8-bit compiler so I am busy...

    towlerg Yesterday, 16:13 Go to last post
    david-48000

    GPS speed logger for RC planes.

    Thread Starter: david

    Hi All, This is a simple project to allow the logging of RC plane speeds to help determine battery, motor and prop variables. The code is crude and...

    david Yesterday, 21:01 Go to last post