DSPRelated.com
Forums

Program help

Started by gaurav_nukala March 25, 2003
Hi all
I am trying to write a program to generate bursts of sinewaves(each
sine wave has three components).Can anyone suggest an modification
this program below

#include<math.h>
#include<trans.h>
#include<21065l.h>
#include<signal.h>
#define pi 3.14159
float out_real[1024],out_imag[1024];
float sig[1024];
float *rfft1024(const float dm sig[],float dm out_real[],float dm
0ut_imag[]);
void main()
{
float t;
int k,l;

for(k=0,t=0;k<1000,t<=0.00001;k++,t=t+0.00000001)

{

sig[k]0*sinf(2*pi*1.5*10e6*t)+100*sinf(2*pi*2.0*10e6*t)
+100*sinf(2*pi*2.5*10e6*t);

if(sig[k]>150||sig[k]<-150)
{
if(sig[k]>150)
sig[k]0;
else
{
if(sig[k]<150)
sig[k]=-150;
}
}

}
for(k00;k<1024;k++)
{
sig[k]=0;
}
rfft1024(sig,out_real,out_imag);
}
The program generates a single burst ..i need a series of bursts...
can it be done using idle()...

Thanks in advance
Gaurav



On Tue, 25 Mar 2003, gaurav_nukala wrote:

> Hi all
> I am trying to write a program to generate bursts of sinewaves(each
> sine wave has three components).Can anyone suggest an modification
> this program below
>
> #include<math.h>
> #include<trans.h>
> #include<21065l.h>
> #include<signal.h>
> #define pi 3.14159
> float out_real[1024],out_imag[1024];
> float sig[1024];
> float *rfft1024(const float dm sig[],float dm out_real[],float dm
> 0ut_imag[]);
> void main()
> {
> float t;
> int k,l;
>
> for(k=0,t=0;k<1000,t<=0.00001;k++,t=t+0.00000001)

This is kind of dangerous. Use k to run the for loop and set up t as a
parameter inside the loop.

> {
>
> sig[k]0*sinf(2*pi*1.5*10e6*t)+100*sinf(2*pi*2.0*10e6*t)
> +100*sinf(2*pi*2.5*10e6*t);
>

I don't know how efficient the compiler is, but you may want to create the
constants for "omega" outside the loop. Then you have
sig[k] = 100*(sinf(w1*t) + sinf(w2*t) + sinf(w3*t))

This is easier for the compiler and more accurate computationally.

> if(sig[k]>150||sig[k]<-150)
> {
> if(sig[k]>150)
> sig[k]0;
> else
> {
> if(sig[k]<150)
> sig[k]=-150;
> }
> }
>
> }
> for(k00;k<1024;k++)
> {
> sig[k]=0;
> }
> rfft1024(sig,out_real,out_imag);
> }
> The program generates a single burst ..i need a series of bursts...
> can it be done using idle()...

Should work fine. Just play with it until it does :-)

Patience, persistence, truth,
Dr. mike



--On Tuesday, March 25, 2003 5:39 PM +0000 gaurav_nukala
<> wrote:

> for(k=0,t=0;k<1000,t<=0.00001;k++,t=t+0.00000001)

The expression "k<1000" does nothing here. The comma operator returns the
value of the second expression. Perhaps you meant to use the "&&" operator?




1. you are defining several global variables,
then using the same variable names in your rfft1024() parameter list.
at best, this is confusing. at worst, it can be a source of much anguish.
2. your "for" loop is poorly constructed.
increment your index k in the for statement, and
increment t within the loop body.
3. what do mean by "a series of bursts"? --- gaurav_nukala <> wrote:
> Hi all
> I am trying to write a program to generate bursts of sinewaves(each
> sine wave has three components).Can anyone suggest an modification
> this program below
>
> #include<math.h>
> #include<trans.h>
> #include<21065l.h>
> #include<signal.h>
> #define pi 3.14159
> float out_real[1024],out_imag[1024];
> float sig[1024];
> float *rfft1024(const float dm sig[],float dm out_real[],float dm
> 0ut_imag[]);
> void main()
> {
> float t;
> int k,l;
>
> for(k=0,t=0;k<1000,t<=0.00001;k++,t=t+0.00000001)
>
> {
>
> sig[k]0*sinf(2*pi*1.5*10e6*t)+100*sinf(2*pi*2.0*10e6*t)
> +100*sinf(2*pi*2.5*10e6*t);
>
> if(sig[k]>150||sig[k]<-150)
> {
> if(sig[k]>150)
> sig[k]0;
> else
> {
> if(sig[k]<150)
> sig[k]=-150;
> }
> }
>
> }
> for(k00;k<1024;k++)
> {
> sig[k]=0;
> }
> rfft1024(sig,out_real,out_imag);
> }
> The program generates a single burst ..i need a series of bursts...
> can it be done using idle()...
>
> Thanks in advance
> Gaurav > _____________________________________
> Note: If you do a simple "reply" with your email client, only the author of
this message will
> receive your answer. You need to do a "reply all" if you want your answer to
be distributed to
> the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to
>
> To Post: Send an email to
>
> To Leave: Send an email to
>
> Archives: http://groups.yahoo.com/group/adsp
>
> Other Groups: http://www.dsprelated.com/groups.php3 > ">http://docs.yahoo.com/info/terms/


===== __________________________________________________



Hi
I wrote a small program that transfers a file from the
BF533 to an another PC through RS232 using UART.
Attached is the program

#include<stdio.h>
#include <cdefbf533.h>

void main(void)
{

FILE *fptr1;
static char val[]= "C:\Documents and
Settings\Adminstrator\Desktop\testfile.txt";
//static int valdup[]={1,2,3,4,5,6,7,8,9,0};
//valdup[10]= (1,2,3,4,5,6,7,8,9 );

fptr1=fopen(val,"r");
//fptr2=fopen("valdup","rb");

//Starting the transfer through DMA using UART
*pDMA7_PERIPHERAL_MAP=0x7000;//setting up the
UART TX DMA regsiter
*pUART_GCTL=0x1;//enabling the UART Clocks
*pUART_LCR=0x0000;//Reset LCR regsiter
*pUART_IER=0x0003;//enabling the receive and
transmit buffer full interrupt
*pDMA7_CONFIG=0x1000;//enabling autobuffer
mode
*pDMA7_START_ADDR=fptr1;//setting the pointer
to the file as the starting address of the DMA
*pDMA7_X_COUNT0;//setting the count
*pDMA7_X_MODIFY=0x1;//modifying register
*pUART_LCR=0x0083;//enabling 8 bits,1stop
bit,no parity
*pUART_DLL=0x001D;//setting the baud rate
*pUART_DLH=0x0000;
*pDMA7_CONFIG=0x0001;//starting the DMA
transfer

} 1.The program compiles but could not get anything at
the terminal program on the PC.
2.On other hand when the change the the starting addr
of the DMA to val i see charecters on the terminal
(c:\documents....)becoz it points to the string array.
That means it prints the charecters.
3.when i changed the type to static char and tried
sending some integer values but i do not receive any.
4.I tried sending a file of charecters even it does
not work.

Plz suggest me where i m going wrong.
Thank u
Regards
sriram

__________________________________



--On Friday, October 10, 2003 10:32 AM -0700 sriram K <>
wrote:

> FILE *fptr1;
> fptr1=fopen(val,"r");
> *pDMA7_START_ADDR=fptr1;//setting the pointer
> to the file as the starting address of the DMA

That won't work. fptr1 points to a FILE structure, not an array of characters
to transmit. Where is this file on your target? You somehow have a filesystem
attached to your BF533? You should be fread'ing from it into a temporary array
and then DMA'ing that to the UART.