• UpCounter.js A 16bit Up Counter Module
    Place UpCounter.js in the modules folder of your WebIDE project.
    Place the TestUpCounterTXChX.js files in the projects folder
    For timers 1, 2, 4, and 5 pin B0 is used as a signal source for testing.
    For timer 3 Pin A0 is used as a signal source for testing.
    For example running TestUpCounter T5Ch1.js produces the following output.
    Note that the timer input pin is the first thing displayed. For testing connect the signal source pin to the timer input pin. Use ClearInterval() to stop the program.

    >echo(0);
    Pin= A0
    =undefined
    CNT=0.5 Hz.
    CNT=976 Hz.
    CNT=972.5 Hz.
    CNT=1006 Hz.
    CNT=1000 Hz.
    CNT=998 Hz.
    CNT=998.5 Hz.
    CNT=999 Hz.
    CNT=999 Hz.
    CNT=999 Hz.
    CNT=999 Hz.
    >clearInterval();
    =undefined
    >
    
    

    To setup several counters on different timers you only need one instance of UpCounter.

    The file Tremap.xlsx shows the pins associated with the timers. It is possible to remap the pins by writing to the remap register. There are unknown pin assignments marked with a question mark. So far I haven’t located a document that gives the pinout of the timers.
    The timers have four channels. The registers CCMR1 and CCMR2 allow the configuration of the 4 channels. The register SMCR only allows channels 1 and 2 and not 3 and 4.


    7 Attachments

About