You are here

why can't we use "goto loop" in psoc3? | Cypress Semiconductor

why can't we use "goto loop" in psoc3?

Summary: 5 Replies, Latest post by Fenn on 05 Sep 2011 05:58 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
user_84545201's picture
User
4 posts

 It's said that PSOC Creator is supported by KEIL,but now,we can't use "goto loop".How can we find another code with the same founction to replace it? 

3Q ~

dasg's picture
Cypress Employee
730 posts

Hi Fenn,

 

When using PSoC 3, Keil Compiler is used in PSoC Creator. Hence, the keywords defined for Keil is applicable to PSoC Creator also.

 

"goto" is used to branch to another location in a program. It transfers the control to the labeled statement whose label matches the Identifier.

 

Consider a simple example as shown below:

 

if (a <= 11)

{

     b = 100;

     goto ESCAPE;

}

b = 50;

ESCAPE:

.........................

.....................

.......................

 

In this code, ESCAPE is the Identifier. When tested in Debug mode on PSoC 3, the "goto" statement executed as expected at my end.

user_84545201's picture
User
4 posts

I want to use PWM-DMA-Filter-DMA-DAC to generate a sinewave,The output of the PWM is a squarewave.However,I can't use the Filter appropriately,neither can I get the correct output.Can you help me?Thanks a lot.

U2
uday's picture
Cypress Employee
569 posts

Fenn, Could you let us know more about your project. I understand from your previous comment that you want to generate a Sine wave from a Square wave by filtering. Can you tell us more about your project implementation - please describe your TopDesign and firmware, so that we can help you out.

user_84545201's picture
User
4 posts

This is the WinRAR files.

user_84545201's picture
User
4 posts

mainfounction:

#include <device.h>
void Configure_DMA_PWM12Filter(void);
void Configure_DMA_Filter2VDAC8(void);
#define TD_DEFAULT  0
/*******************************************************************************
* Function Name: Configure_DMA_PWM2Filter
********************************************************************************
* Summary:
*  The function configures the DMA channel named DMA_PWM12Filter for transfering the PWM data to the Filter
*
* Parameters: 
*  None
*
* Return:
*  (void)
*
* Theory:
*
* Side Effects:
*
*******************************************************************************/
void Configure_DMA_PWM12Filter(void)
{

 uint8 DMA_PWM12Filter_Chan;
 uint8 DMA_PWM12Filter_TD[1];
 

 #define DMA_PWM12Filter_BYTES_PER_BURST 1
 #define DMA_PWM12Filter_REQUEST_PER_BURST 1
 #define DMA_PWM12Filter_SRC_BASE (CYDEV_PERIPH_BASE)
 #define DMA_PWM12Filter_DST_BASE (CYDEV_PERIPH_BASE)
 DMA_PWM12Filter_Chan = DMA_ADC2Filter_DmaInitialize(DMA_PWM12Filter_BYTES_PER_BURST, DMA_PWM12Filter_REQUEST_PER_BURST,
  HI16(PWM_1_CONTROL_PTR), HI16(Filter_STAGEAM_PTR));
 DMA_PWM12Filter_TD[0] = CyDmaTdAllocate();
 CyDmaTdSetConfiguration(DMA_PWM12Filter_TD[0], 1, DMA_PWM12Filter_TD[0], 0);
 CyDmaTdSetAddress(DMA_PWM12Filter_TD[0], LO16((uint32)PWM_1_CONTROL_PTR), LO16((uint32)Filter_STAGEAM_PTR));
 CyDmaChSetInitialTd(DMA_PWM12Filter_Chan, DMA_PWM12Filter_TD[0]);
 CyDmaChEnable(DMA_PWM12Filter_Chan, 1);
 
}

/*******************************************************************************
* Function Name: Configure_DMA_Filter2VDAC8
********************************************************************************
* Summary:
*  The function configures the DMA channel named DMA_Filter2VDAC8 for transfering the Filter output data to the VDAC
*
* Parameters: 
*  None
*
* Return:
*  (void)
*
* Theory:
*
* Side Effects:
*
*******************************************************************************/
void Configure_DMA_Filter2VDAC8(void)
{
 /* The code below is copied from the DMA Wizard */
 /* Variable declarations for DMA_Filter2VDAC8 */
 uint8 DMA_Filter2VDAC8_Chan;
 uint8 DMA_Filter2VDAC8_TD[1];
 
 /* DMA Configuration for DMA_Filter2VDAC8 */
 #define DMA_Filter2VDAC8_BYTES_PER_BURST 1
 #define DMA_Filter2VDAC8_REQUEST_PER_BURST 1
 #define DMA_Filter2VDAC8_SRC_BASE (CYDEV_PERIPH_BASE)
 #define DMA_Filter2VDAC8_DST_BASE (CYDEV_PERIPH_BASE)
 DMA_Filter2VDAC8_Chan = DMA_Filter2VDAC8_DmaInitialize(DMA_Filter2VDAC8_BYTES_PER_BURST, DMA_Filter2VDAC8_REQUEST_PER_BURST,
  HI16(Filter_HOLDAM_PTR), HI16(VDAC8_Data_PTR));
 DMA_Filter2VDAC8_TD[0] = CyDmaTdAllocate();
 CyDmaTdSetConfiguration(DMA_Filter2VDAC8_TD[0], 1, DMA_Filter2VDAC8_TD[0], 0);
 CyDmaTdSetAddress(DMA_Filter2VDAC8_TD[0], LO16((uint32)Filter_HOLDAM_PTR), LO16((uint32)VDAC8_Data_PTR));
 CyDmaChSetInitialTd(DMA_Filter2VDAC8_Chan, DMA_Filter2VDAC8_TD[0]);
 CyDmaChEnable(DMA_Filter2VDAC8_Chan, 1);
 /* The code above is copied from the DMA Wizard */
}
 
void main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
 PWM_1_Start();

 
 CYGlobalIntEnable;   /* Uncomment this line to enable global interrupts. */

 /* Variable declarations for DMA */
/* Move these variable declarations to the top of the function */
 
 /* Start VDAC8 */
 VDAC8_Start();
 
 /* Start filter */
 Filter_Start();
 
 /* Filter Coherency set to mid byte */
 Filter_COHER_REG = 0x55;

 
 /* Configure the DMA to transfer from ADC to Filter */
 Configure_DMA_PWM12Filter();
 
 /* Confgure the DMA to transfer from Filter to DAC */
    Configure_DMA_Filter2VDAC8();
 

 for(;;)
    {
       //Filter_Write8(Filter_CHANNEL_A, ~ PWM_2_CONTROL_PTR);
      // Filter_Write8(Filter_CHANNEL_A, 1);
  /* Place your application code here. */
    }
}

/* [] END OF FILE */

The TopDesign is:

PWM_1(tc)----DMA_ADC2Filter(drq)---Filter----DMA_Filter2VDAC8---VDAC8

I don't know how to "move" those sample values from the PWM_1's Register into the Filter's Register. o(∩_∩)o...

3Q~~

Log in to post new comments.