AnsweredAssumed Answered

PPI simple example

Question asked by vito on Feb 2, 2012

Hi,

 

I'm having problems with basic PPI mode (TX mode 0):

  • To narrow the problem - I drove PPI_CLK with GPIO instead of Timer.
  • everytime I run it - I got different results on scope (see attached pictures).
  • Im trying to get pattern 1010 1010 1010 1010 on scoped D15 line, but without any success
  • Please see attached zipped pictures from scope:
    • Attached are consecutive runs of following function
    • First of all - it is not a pattern I expect (it has numbers of zeros at the beginning and it breaks)
    • Second - if you compare tek00021.png vs tek00022.png - you will see
      same pattern shifted by 1 clock (what is wrong???)

 

I appreciate your help a lot.

 

 

static void adi_ppi_transmission4_ez_problem(void)
{
    int a, b, i;
    int addr = 0x0101; // 0x01 << 8;

 

 

    int length = 16;
    u16 buff[8] = { 0xFFFF, 0x0000, 0xFFFF, 0x0000,
                    0xFFFF, 0x0000, 0xFFFF, 0x0000,
                    0xFFFF, 0x0000, 0xFFFF, 0x0000,
                    0xFFFF, 0x0000, 0xFFFF, 0x0000 };
          

    // PH2 drives external buffer bus expander

    *pPORTHIO_DIR |= (1<<2); // PH2 to output (ADI_HOIF_DIR_GPIO2_CONA)
    *pPORTHIO_CLEAR = (1<<2); // PH2 to low (ADI_HOIF_CLEAR_GPIO2_CONA)
   
    // port F: PPI
    *pPORTF_FER = 0xFFFF; // switching to PPI
    *pPORTF_MUX |= (1 << 12); // Table 1-3 says SET 1<<12 to DISABLE; Page 9-5 says "If bit 12 is set to 1, the PPICLK/TMRCLK is enabled". http://www.analog.com/static/imported-files/processor_manuals/BF52xHRM_Rev.1.0.pdf

 

    ///////////////////////////////////////////////
    // PG7 is a signal connected to and driving PPI_CLK
    *pPORTG_FER &= ~(1<<7); // Switching PG7 to GPIO
    *pPORTGIO_INEN &= ~(1<<7); // Disabling PG7 as an input
    *pPORTGIO_SET = (1<<7); // Seting high values on PG7
    *pPORTGIO_DIR |= (1<<7); // Setting PG7 to output

 

    // set up DMA for transfer:
    // as per 21-38 Programming examples modified to 16-bits:
    //  http://healthcare.analog.com/static/imported-files/processor_manuals/34320671753594BF52xPeriphHWR03.pdf)
    *pDMA0_CONFIG = FLOW_STOP | DI_EN | (0x01 << 2); // (0x01 << 2) -> WDSIZE=0x01 for 16 bit data, DI_EN set as in the example
    *pDMA0_START_ADDR = buff;
    *pDMA0_X_COUNT = length; // this shouldnt matter (21-35 says "PPI is used in all modes except for TX mode with 0 frame syncs)
    *pDMA0_X_MODIFY = 2; // 2 for 16-bit data
    ssync();

 

    *pPPI_DELAY = 0;
    *pPPI_COUNT = length-1; // as per AN-813, Listing 2: PPI_COUNT=DMA0_X_COUNT-1  (http://www.analog.com/static/imported-files/application_notes/AN-813.pdf)
    ssync();

 

    /* Setting PPI Control to mode 0: TX PORT_DIR=1, PORT_CFG=00, XFR_TYPE=0; */
    /* Setting PPI CONTROL to:
    //  TX mode 0:
          XFR_TYPE=0
          PORT_DIR = 1
          PORT_CFG = 00
          POLC = 0 or 1
          POLS = 0 or 1         
        (as per Table 21-4 and Table 21-4 in
        http://healthcare.analog.com/static/imported-files/processor_manuals/34320671753594BF52xPeriphHWR03.pdf)
    */   
    *pPPI_CONTROL = PORT_DIR | (0x7 << 11); // 7 = DLENength (15 bits), PORT_EN, PORT_DIR to output,
    ssync();
    *pDMA0_CONFIG |= DMAEN; // BIT 0: ENABLE transfer!
    ssync();
    *pPPI_CONTROL |= PORT_EN; // Enable PPI
    ssync();

 

 

    // Sending clocks on PG7 to PPICLK (TRANSMISSION)
    for (i=0; i        *pPORTGIO_TOGGLE = (1<<7); // PG7 high -> low
        ssync();
        *pPORTGIO_TOGGLE = (1<<7); // PG7 low -> high
        ssync();               
    }   

    // End of transmission

    *pDMA0_IRQ_STATUS |= 0x0001; // Clear completition flag   
    ssync();
    *pDMA0_CONFIG &= ~DMAEN; // DISABLE DMA
    ssync();   
}

Attachments

Outcomes