This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/PGA900EVM: COMBUF and PADC

Part Number: PGA900EVM
Other Parts Discussed in Thread: PGA900

Tool/software: Code Composer Studio

I am trying to communicate with the pga90 using I2C to read PADC values.

In the COMBUF interrupt service routine (COMBUF_Handler(void)?) I would like to read COM_DIF_TO_MCU data from the master, interpret it, read the register of interest (PADC), then make it so that the pga900 periodically updates the COM_MCU_TO_DIF.

I am trying to get this data for  PADC_DATA1 & PADC_DATA3 then periodically write this to COM_MCU_TO_DIF (24-bit mode, PADC_DATA1 is LSbyte and PADC_DATA3 MSbyte)

I would like to have a function for example:

void readPADC_DATA1 (UC PADC_DATA1)

{

(????????) // This is what I am not sure I need to fill in to get a function that reads the PADC_DATA1 & PADC_DATA3

}

Which I can then call in the COMBUF interupt service routine so that my I2C master can read:

ADCMSByte = readPADC_DATA1 ()

COM_MCU_TO_DIF_write(ADCMSByte);

The reference code has all these below but I am not sure which one actually contains the ADC values that I can update the COM_MCU_TO_DIF with so that my I2C master can read. Sorry I am a beginner so It is not so obvious for me! 

#define PADC_DATA1 (*((VUC *)0x40000520)), #define PADC_DATA3 (*((VUC *)0x40000522)),

#define PADC_DATA (*((VS2 *)0x40000520)),    #define PADC_DATA_24BIT (*((VSL *)0x40000520))

VS2 ADC_PchannelValue;  /* PADC Value */  &   interrupt void PADC_Handler(void)

  • Hello,

    The PADC_Handler function should read the PADC for you and put the full 24 bits into the ADC_PchannelValue variable. No need to split it into MS and LS sections.

    Does this answer your question? Please let me know if you meant something different.

    Regards,
  • Please correct me if I am wrong but is this what the reference firmware does if communicating through I2C?

    1.Master sends some data e.g (0x20) to [ COM_DIF_TO_MCU reg 0x40].

    2. An interrupt is generated in the PGA900 register interrupt void COMBUF_Handler(void)

    3. COMBUF_Handler Reads this data and temporarily stores it to Combuf_rx_buf ( COMBUF_Rx_Buf[0] = COM_DIF_TO_MCU_B;),

    Clears receive status and Flags to process the data.

    4. in the main Function the Inverse of this temporarily stored data is what the i2c Master receives back?

    COM_MCU_TO_DIF_B = ~COMBUF_Rx_Buf[0]; /* Transmit BITWISE Not of received data */ 

     

     If my interpretation is correct then for getting a PADC readings is this okay?:

    1. Master sends some data e.g (0x20) to [ COM_DIF_TO_MCU reg 0x40]

    2. An interrupt is generated interrupt void COMBUF_Handler(void)

    3.  I modify the COMBUF_Handler(void) to look like:

    interrupt void COMBUF_Handler(void)

    {

       COMBUF_Rx_Buf[0] = COM_DIF_TO_MCU_B; /* Read combuf data */

         /* read PADC and put the full 24 bits in ADC_PchannelValue variable */

       while (COMBUF_Rx_Buf[0] == 0x20){

              PADC_Handler(ADC_PchannelValue); /* not sure how to call the padc_handler & return ADC_PchannelValue if it has no parameters and returns nothing*/

              }                                                             /*help will be appreciated */

       COMBUF_Rx_Buf[0] = ADC_PchannelValue;

       COMBUF_RX_STATUS_CLEAR();            /* Clear receive status */

       COMBUF_Flag = 1;

    }

    4. In the main Function the master will receive this  ADC_PchannelValue

     /* Transmit received data */

     COM_MCU_TO_DIF_B = COMBUF_Rx_Buf[0];