• PicŪ Basic


  • CountUntil

    A library module for use withLibrary Manager by JohnGB. This module has been written by Tim Box (Tim on PDS forum). The library module is offered on an as-is basis with no warranty as to its effectiveness, operation or reliability. Users use it at their own risk.

    Adds a new command called CountUntil

    Syntax

    Variable = CountUntil Port1, Pin1, Port2, Pin2, StopPinLevel

    Overview

    Count the number of pulses that appear on pin Until another pin equals the trigger level, and store the result in variable

    Operators

    Variable - a user-defined variable (byte word or dword).

    Port1 - a port or a byte variable or constant that represents the port address that the pulse is being counted on

    Pin1 - a pin number between 0 and 7 represented as a constant or byte that the pulse is being counted on

    Port2 - a port or a byte variable or constant that represents the port address that stops the count

    Pin2 - a pin number between 0 and 7 represented as a constant or byte that stops the count

    StopPinLevel - a constant or variable that represents the logic level to stop the counting 0 or 1

    Code:
    ' Count the pulses that occur on PORTA.0 until PORTA.1 goes high and display the results. 
        Dim WRD As Word          ' Declare a word size variable 
    
    Loop:
        Cls  
        WRD = CountUntil PORTA,0,PORTA,1,1  ' Variable WRD will contain the Count result
        Cursor 1 , 1 
        Print Dec WRD , " "      ' Display the decimal result on the LCD 
        GoTo Loop                ' Do it indefinitely
    Notes:

    The counter is incremented on the rising edge of a transition (low to high).

    The maximum value the count can obtain is 65535


    Download module

    Download: CountUntil
  • Recent Activity

    teo-16018

    Microsoft security essentials blues

    Thread Starter: shantanu@india

    Hi, A strange thing happened just now.My Windows 7 Micrsoft Sercurity Essentials suddenly gave a warning that prplus.exe(Compiler) is a potential...

    teo Today, 19:23 Go to last post
    pic-ignorant-1162

    Proton Runtime Error

    Thread Starter: Paulcc

    I have proton running well on my laptop, but after installing it on my desktop, I get the following runtime error: "Runtime Error 217 at 000709FC" I...

    pic-ignorant Yesterday, 22:11 Go to last post
    David Barker-251

    UMC bootloader 18F46K22

    Thread Starter: shunt010

    Hi all. I am trying to build a UMC bootloader file for the 18F46K22, and it doesn't appear to work. It returns (in the error log) Error ...

    David Barker Today, 11:20 Go to last post
    barak-1433

    SPI mssp

    Thread Starter: picprotonguy

    Just ordered Digital to Analog IC MCP4822 with SPI interface and immediately opened proton manual. I'm very disappointed, it looks like Proton...

    barak Today, 16:06 Go to last post