Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > mutiple channel sine wave generator based on DAC_SineWaveGenerator

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



mutiple channel sine wave generator based on DAC_SineWaveGenerator
Moderator:
ANCY

Post Reply
Follow this topic



mutiple channel sine wave generator based on DAC_SineWaveGenerator

Johnspark posted on 07 Oct 2010 11:29 PM PST
Member
8 Forum Posts

Dear community, I want to make a multiple channel sinewave generator which can have configurable amplitude and phase. Frequency only has to be 50 / 60 hertz. Ideally I would like 8 channels but can settle for 4.

From the example called :DAC_SineWaveGenerator, I understand for 1 channel, I need 1 timer, 1 DMA and 1 VDAC.

For 4 channels I would need 4 DMAs, 4 VDACs but what do I do with the timing, do i use 4 timers, or 1 timer plus 3 shift registers? What is the best way to go?

many thanks

For the time being I am happy to have a register or simple way to store the phase and amplitude data.

kind regards,

John




Re: mutiple channel sine wave generator based on DAC_SineWaveGenerator

Johnspark posted on 26 Oct 2010 11:07 PM PST
Member
8 Forum Posts

 

 

Many Thanks in Advance!

Dear community, I have made some snail progress and have produced the following code as well as added a second DMA and VDAC_8 onto the *.cysch  page, as part of my developing the final solution:

 

#include

<device.h>

#define

 

TABLE_LENGTH 32

void

{

 

176,152,127,103,79,57,38,22,10,3,0,3,10,22,38,57,79,103};

 

 

 

 

 

main()uint8 sineTable[32] = {127,152,176,198,217,233,245,252,254,252,245,233,217,198,uint8 channel, channel_2; uint8 td,td_2; /* Start the DAC,PWM and enable the clock */

 

VDAC8_Start();

VDAC8_1_Start();

Timer_Start();

 

 

 

* Request per burst - 1 (every burst needs a new request

* High byte of source address = 0 (as SRAM is within 16 bit address space)

* High byte of Destination address = 0 (as it resides within 16 bit address space) */

#if (defined(__C51__))/* Initailize the DMA Channel will Burst count of 1 (to send 1 byte at a time)

 

channel = DMA_DmaInitialize(1, 1, 0, 0);

channel_2 = DMA_2_DmaInitialize(1,1,0,0);

 

 

#else

 

 

* Request per burst - 1 (every burst needs a new request

* High byte of source address = The upper 16 bits of source address is initialized with

* only one variable because the base address will be same for all the variables in the

* pattern and only the offset changes

* High byte of destination address = 0 (the UDB control register resides in 16 bit address space */

/* Initailize the DMA Channel will Burst count of 1 (to send 1 byte at a time)

 

channel = DMA_DmaInitialize(1, 1, HI16(sineTable), HI16(VDAC8_viDAC8__D) );

channel_2 = DMA_2_DmaInitialize(1, 1, HI16(sineTable), HI16(VDAC8_2_viDAC8__D) );

 

 

 

#endif /* Allocate the td with the channel that was allocated */

td = CyDmaTdAllocate();

td_2 = CyDmaTdAllocate();

 

 

/* Configure the td to transfer 32 bytes of data with auto increment of source address and no following TD */

CyDmaTdSetConfiguration(td, TABLE_LENGTH, td, TD_INC_SRC_ADR);

CyDmaTdSetConfiguration(td_2, TABLE_LENGTH, td_2, TD_INC_SRC_ADR);

 

 

/* Set the lower 16 bits of source address and the destination adddress */

CyDmaTdSetAddress(td, LO16((

CyDmaTdSetAddress(td_2, LO16((

 

 

uint32)sineTable), LO16((uint32)VDAC8_viDAC8__D) );uint32)sineTable), LO16((uint32)VDAC8_2_viDAC8__D) );/* Set tds to be the initial td associated with channel */

CyDmaChSetInitialTd(channel, td);

CyDmaChSetInitialTd(channel_2, td_2);

 

 

/* Enable the DMA channel */

CyDmaChEnable(channel, 1);

CyDmaChEnable(channel_2, 1);

 

 

 

(;;)

{

 

}

for

Would someone please help me get this second DMA channel (DMA_2) to read exactly the same look up table value as DMA channel one (DMA), and send to my second VDAC_8 called (VDAC_8_1) , the first VDAC_8 is still called (VDAC_8).  I am a novice at the moment, but will learn as time permits..

./main.c: In function 'main':

./main.c:93: error: 'VDAC8_2_viDAC8__D' undeclared (first use in this function)

The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

--------------- Build Failed: 10/25/2010 08:08:23 ---------------

 



Re: mutiple channel sine wave generator based on DAC_SineWaveGenerator

Gautam Das posted on 27 Dec 2010 11:24 AM PST
Cypress Employee
742 Forum Posts

Hi Johnspark,

 

Can you please post the error messages/ warnings you are getting while building this project?

 

Regards,

dasg



Re: mutiple channel sine wave generator based on DAC_SineWaveGenerator

Johnspark posted on 06 Jan 2011 02:43 PM PST
Member
8 Forum Posts

Hi Dasg,

I am now using 8 PWMs instead of 4 DACs but continue making snail progress. Have now read many PSoC articles as well as looked at lots of c forums, still making slow progress.

Currently, I have the following code with 2 errors and would greatly appreciate help to progress:

 

 I have a sine look up table with this in the header:

#define

 

 

 

 

 

 

 

 

SINE_TABLE_SIZE 65536

const  unsigned short  Sine_Table_unsigned_short[SINE_TABLE_SIZE];

 

I have this in the sine look up table c file:

 

#include "SineLut.h"

const

{

32768

unsigned short Sine_Table_unsigned_short[SINE_TABLE_SIZE] =

...

32761 ,

32764

};

/* [] END OF FILE */

I have this in the main.c file:

 DMA_1_TD[0] = CyDmaTdAllocate();

 

 

 

CyDmaTdSetConfiguration(DMA_1_TD[0],

 

sizeof(Sine_Table_unsigned_short), DMA_1_TD[0], TD_INC_SRC_ADR);// Set the source to be the waveform and the destination to be the PWM

CyDmaTdSetAddress(DMA_1_TD[0], (

 

unsigned short)Sine_Table_unsigned_short,(uint16)((uint16) PWM_1_COMPARE1_LSB_PTR));

 

 

and these are the 2 warning errors:

large implicitly truncated to unsigned type (for CyDmaTdSetConfiguration line)

cast from pointer to integer of different size (for CyDmaTdSetAddress line)

 

 

any help would be greatly appreciated Dasg,

cheers Johnspark

 

 

 

 



Re: mutiple channel sine wave generator based on DAC_SineWaveGenerator

Johnspark posted on 24 Jan 2011 10:51 PM PST
Member
8 Forum Posts

Dear All, I have managed to clear up the errors so thanks anyway on this post,

 

 

cheers JohnSpark



Re: mutiple channel sine wave generator based on DAC_SineWaveGenerator

Gautam Das posted on 27 Jan 2011 05:19 AM PST
Cypress Employee
742 Forum Posts

Hi Johnspark,

 

Can you please share with us the error which you were facing?

It will be helpful to all members.

 

Thanks in advance,

dasg






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20