ts-7000
[Top] [All Lists]

[ts-7000] user level access to timer 3

To:
Subject: [ts-7000] user level access to timer 3
From: "w_heller2000" <>
Date: Thu, 25 Sep 2008 00:08:18 -0000
I am trying to get timer3 working on a TS-7200 I have taken the 
T4ticks.c code as a starting point and changed it to address timer3 
and also changed the location of the enable bit what I am finding is 
the timer is not starting ie the value register doesn't increment 
after I write to the load register and set the enable flag. If anyone 
has suggestions please pass them along. 

Here is the code as of now.
//T3ticks.c
#include<unistd.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<stdio.h>
#include<fcntl.h>
#include "T3ticks.h"

// Global pointes to T3value and T3load registers (0x80810080 & 
0x80810084).

unsigned int *t3value,*t3load,*t3control,*t3clear;
int fd,temp;
unsigned char *start;

// T3ticks_ms() - Returns a counter which increments at approx 1ms 
rate.

unsigned long T3ticks_ms()
{
        return (unsigned long)(*t3value >> 9);
}

// T3ticks_raw() - Returns a counter which increments at full speed 
(2kHz).

unsigned long T3ticks_raw()
{
        return (unsigned long)(*t3value);
}

// start_T3() - Starts the counter and sets up T4 memory pointers.

int start_T3()

{
        unsigned char *start;

        int fd = open("/dev/mem", O_RDWR);
        start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, 
MAP_SHARED, fd, 0x80810000);

        t3value = (unsigned int *)(start + 0x80);
        t3load = (unsigned int *)(start + 0x84);
        t3control = (unsigned int *)(start + 0x88);
        t3clear = (unsigned int *)(start + 0x8c);

//      t3control = 0x00;               // disable timer
//      *t3load = 0x80000000;
//      temp = *t3value;
        *t3control = 0x80;              // Enable timer
//      printf("Timer 3 control word 0x%X and value 0x%
X\n",*t3value,temp);
        return fd;
}


// Reset T3 - Set T3 back to zero.

int T3_reset()
{
        *t3control = 0;
        *t3clear = 0;
}

/*
        Test program which starts timer, and sets to pulse outputs at 
different frequencies.
        
        At each point in time it prints the 1ms and raw timer 
readings.
*/ 

int main(int argc, char **argv)
{
        unsigned long TimeNow,EndTime,Pulse1Time,Pulse2Time;
        
        int fd=start_T3();              // Start Timer (does not 
clear)


        /* Reset is demonstrated but not recommended
           as T3 could be used by another program */

        //T3_reset();                                           // 
Reset T4 to zero        
        
        TimeNow=T3ticks_ms();
        EndTime=TimeNow+10000;
        Pulse1Time=TimeNow+250;
        Pulse2Time=TimeNow+1000;

        printf("Start: 0x%X 0x%X\n",TimeNow,T3ticks_raw());
        printf("Pulse times 0x%X 0x%X\n",Pulse1Time,Pulse2Time);
        while ((TimeNow=T3ticks_ms())<EndTime)
        {
                if (TimeNow>Pulse1Time) 
                {
                        printf("Pulse1: %lx %llx\n", TimeNow, 
T3ticks_raw());
                        Pulse1Time+=250;
                }
                if (TimeNow>Pulse2Time) 
                {                    
                        printf("Pulse2: %lx %llx\n", TimeNow, 
T3ticks_raw());
                        Pulse2Time+=1000;
                }
        }
        printf("End: %lx %llx\n", TimeNow,T3ticks_raw());
        
        close(fd);
}


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU