ts-7000
[Top] [All Lists]

[ts-7000] Generate a PWM wave

To:
Subject: [ts-7000] Generate a PWM wave
From: "jvonrudnocruz" <>
Date: Tue, 01 Nov 2011 11:57:41 -0000
Hello everybody,

It is my first time that i write in our group,

My problem is the next:

I am using a TS7260 and I am trying to geneate a square wave with diferent 
frequencies and I need that every period is 1 second and the time of the every 
peak should be 10 ms.

When i read the documentation, I have found the next method to generate a 
square wave with the next parameter:

int startPWM(xdio *x, int freq, int microDutyCicle)

my problem is that I can not reach the way to make time of every peak of 10 ms.

I was develop the next code to do this:

struct xdio xdio1,xdio2,*xd1=0,*xd2=0;
JNIEXPORT jboolean JNICALL Java_wave_GenerateWave_wave(JNIEnv *env, jobject 
obj, jintArray frequencies)
{
        //Initialize variables and take a copy of the array of frequencies.
        jsize i;
        jsize sizeVector = (*env)->GetArrayLength(env, frequencies);
        jint* frequency;

        frequency = (*env)->GetIntArrayElements(env, frequencies, NULL);

        //Open the xdio1 and xdio2
        if (open_xdio(&xdio1,0))
        {
                xd1 = &xdio1;
        }
        if (open_xdio(&xdio2,1))
        {
                xd2 = &xdio2;
        }

        //Set pin 4 as output direction.
        setPinDirection(xd1,4,OUTPUT);
        setPin(xd1, 4, LOW);

        int ret = 0;
        //Execute the method in xdio.c to obtain a pwm.
        for (i=0; i<sizeVector; i++)
        {
                initCounter(xd1,EDGE_COUNTER,NO_RESET);
                setClockSpeed(xd1,1);

                ret = startPWM(xd1,frequency[i],990000);

                if(ret == 0)
                {
                        return ret;
                }

                printf("Frequency[%d] = %d\n", i, frequency[i]);

                printf("return value of the method: %d\n ", ret);
                pausePWM(xd1);

                usleep(970000);
        }

        resumePWM(xd1);

        //release the copy of the array
        (*env)->ReleaseIntArrayElements(env, frequencies, frequency, 0);

        //Close the xdio
        close_xdio(xd1);
        close_xdio(xd2);
        return 1;
}

I hope I someone can give a hand.

Regards.

Jorge von Rudno. 



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

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>
  • [ts-7000] Generate a PWM wave, jvonrudnocruz <=
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