cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

Hello Every One,

   

I am trying to implement polling method for channel A and channel B of my filter.

   

I am following and example project. This project is written for Channel A only. I have some confusion in it. I wrote the following code for channel A and B. Kindly tell me if am i am doing it write:

   

I am doing the following:

   

ADC---->Filter---->DAC.

   

Code:

   


#include <device.h>
#include <VDAC8.h>
#include <math.h>
#include <stdio.h>
    
void DMA_ADC_ChA_Config(void);

   

void DMA_ADC_ChB_Config(void);

   

int main()
{

   

 ADC_ChA_Start();
    ADC_ChA_IRQ_Start();
    ADC_ChA_StartConvert();
    ADC_ChB_Start();
    ADC_ChB_IRQ_Start();
    ADC_ChB_StartConvert();
    VDAC_ChA_Start();
    VDAC_ChB_Start();
    Filter_Start();
     Filter_INT_CTRL_REG |= (1 << Filter_CHANNEL_A);
     Filter_INT_CTRL_REG |= (2 << Filter_CHANNEL_B); (IS THIS COMMAND IS CORRECT FOR CHANNEL B?)

   

DMA_ADC_ChA_Config();
   
    DMA_ADC_ChB_Config();

   


    /* Enable Global Interrupts */
    CYGlobalIntEnable;

   

for(;;)
    {
       
        while (Filter_IsInterruptChannelA() == 0) ;
        VDAC_ChA_SetValue(Filter_Read8(Filter_CHANNEL_A) + 128u);

   

        while (Filter_IsInterruptChannelB() == 0);
        VDAC_ChB_SetValue(Filter_Read8(Filter_CHANNEL_B) + 128u);
    }
} /* End of main

   

 

   

Looking forward for your reply.

   

Awais

0 Likes
Reply
1 Solution
Esteemed Contributor II

Do not use "while", this can skip a result in the other channel. Use if(Filter_IsInterruptChannelA() )

   

Do not forget to remove/disable your interrupt component.

   

 

   

Bob

View solution in original post

0 Likes
Reply
3 Replies
Esteemed Contributor II

Do not use "while", this can skip a result in the other channel. Use if(Filter_IsInterruptChannelA() )

   

Do not forget to remove/disable your interrupt component.

   

 

   

Bob

View solution in original post

0 Likes
Reply
Anonymous
Not applicable

Thankyou for your reply.

   

Yes i used "if command".

   

Also for channel B: Filter_INT_CTRL_REG |= (2 << Filter_CHANNEL_B); is this command is correct? I didnt find enough explanation about this command.

   

 

   

Awais

0 Likes
Reply
Esteemed Contributor II

No, do a Filter_INT_CTRL_REG |= 0x03 to enable channel A and B.

   

Filter_INT_CTRL_REG |= (1 << Filter_CHANNEL_B);  might work, but "ich hab keine Lust nachzusehen, mach Du das" 😉

   

 

   

Bob

0 Likes
Reply