AnsweredAssumed Answered

24 bit PPI output example

Question asked by Jeroen_ on Jul 4, 2018

Hello, 

 

I am working on an ADSP SC584 EZBoard with CCES 2.7. 

I need to control a 24 bit DDS which is connected to the EZBoard with a custom extension board through connector P1A. 

 

I want to use the ADI PPI driver (adi_ppi.h). (as I guess that is the most save way)

I have searched over the internet but I couldn't find a example of this. 

When I look in "Browse Examples" there is a very summary example: "PPI driver callback mode". 

 

That is the start point which I used to build my own PPI test. 

To test the PPI I want to write all 24 bits high and low a few times and when the PPI is finished I would like to get an interrupt so I known that the PPI is ready to continue with a next write. 

 

This is not yet working; the PPI is not sending data out of the PPI pins. 

 

Questions:

1. How do I send data out of the PPI bus? 

2. Is it possible to toggle a sync pin after the data is set on the PPI pins? 

3. Is it possible to toggle a second sync pin every second time data is set on the PPI pins? (So the first sync pin is always toggled and the second sync pin is skipping one sample every time. )

 

Below I have attached my test code. 

 

Best regards,

Jeroen

 

 

#if defined (__ADSPARM__)
/* Some variables in this code sketch are set for demonstration purposes
* but not used. These variables are expected to be used in real
* applications.
*/

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#include <drivers/ppi/adi_ppi.h>
#include <stdio.h>
/* Managed drivers and/or services include */
#include "../system/adi_initialize.h"
#include <services/gpio/adi_gpio.h>
#include <services/int/adi_int.h>
/* Evaluation board configuration function. */
extern void ConfigSoftSwitches(void);

#define DEBUGPIN ADI_GPIO_PIN_9
/* flag indicating if PPI processing is complete */
static bool bComplete = false;
/* PPI callback */
void PpiCallback(void* pHandle, uint32_t u32Arg, void* pArg)
{
ADI_EPPI_HANDLE pDevice = (ADI_EPPI_HANDLE *)pHandle;
ADI_EPPI_EVENT event = (ADI_EPPI_EVENT)u32Arg;
uint16_t *data = (uint16_t*)pArg;
switch (event) {
case ADI_EPPI_DMA_BUFFER_PROCESSED:
bComplete = true;
break;
default:
break;
}
*pREG_PORTC_DATA_TGL = DEBUGPIN; // Toggle
}


int main(void)
{
/* EPPI driver handle */
ADI_EPPI_HANDLE hDevice;
/* EPPI driver memory */
uint8_t driverMemory[ADI_EPPI_MEMORY_SIZE];
/* driver API result code */
ADI_EPPI_RESULT result;
/* Tx buffers */
uint32_t TxBuffer1[1024];
uint32_t TxBuffer2[1024];
uint32_t counter = 0;
bool high = false;
// Fill the buffer
for(counter = 0; counter< 1024; counter++){
if(high == false){
TxBuffer1[counter] = 0x0;
high = true;
}
else{
TxBuffer1[counter] = 0xFFFFFFFF;
high = false;
}
}
/* Initialize managed drivers and/or services */
adi_initComponents();
/* Software Switch Configuration for the EZ-BOARD. */
ConfigSoftSwitches();
// Debug pin
*pREG_PORTC_FER_CLR = DEBUGPIN; // GPIO
*pREG_PORTC_DATA_CLR = DEBUGPIN; // Low
*pREG_PORTC_DIR_SET = DEBUGPIN; // Output

/* EPPI0 full memory access. */
*pREG_SPU0_SECUREP95 = 0x3u;
/* DMA28 full memory access. */
*pREG_SPU0_SECUREP107 = 0x3u;
/* open the EPPI driver */
result = adi_eppi_Open(0, ADI_EPPI_DIRECTION_TX, driverMemory, (uint32_t)ADI_EPPI_MEMORY_SIZE, &hDevice);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
/*
* Use the driver API's to configure EPPI
*
* adi_eppi_SetITUMode();
* adi_eppi_SetFSMode();
* adi_eppi_SetDataLength();
* adi_eppi_SetDmaTransferSize();
* adi_eppi_SetClockDivide();
*
* adi_eppi_SetFrameSync1();
* adi_eppi_SetHorizontalDelay();
* adi_eppi_SetSamplesPerLine();
* adi_eppi_SetHorizontalCount();
*
* adi_eppi_SetFrameSync2();
* adi_eppi_SetVerticalDelay();
* adi_eppi_SetLinesPerFrame();
* adi_eppi_SetVerticalCount();
*/

// Set PPI in General perpose mode
result = adi_eppi_SetITUMode(hDevice, ADI_EPPI_GENERAL_PURPOSE);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
// Set the PPI in Frame sync mode 1
// Hardware reference manual page 859:
// "General-Purpose 1 Frame Sync Mode
// This mode is useful for interfacing the EPPI with analog-to-digital converters (ADCs), digital-to-analog converters
// (DACs), and other general-purpose devices. This mode works for both transmit and receive."
result = adi_eppi_SetFSMode(hDevice, ADI_EPPI_FS_MODE0);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
// Set on 24 bit
result = adi_eppi_SetDataLength(hDevice, ADI_EPPI_24BIT);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
// Set the DMA on 32 bit transfers (as 16 bit is too small and 24 is not available).
result = adi_eppi_SetDmaTransferSize(hDevice, ADI_EPPI_DMA_TRANSFER_32BIT);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
// Keep the clock divider on 1.
// EPPI_CLK = (SCLK1_0) / (EPPI_CLKDIV + 1)
result = adi_eppi_SetClockDivide(hDevice, 3);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
// Use external clock
result = adi_eppi_SetInternalClk(hDevice, true);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}

/* Register a callback for the DMA */
result = adi_eppi_RegisterCallback(hDevice, PpiCallback, NULL);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
/* submit the EPPI buffers */
result = adi_eppi_SubmitBuffer(hDevice, &TxBuffer1, 16);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
// Start the PPI
result = adi_eppi_Enable(hDevice, true);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}

for(counter = 0; counter <10; counter++){
while(!bComplete)
{
/* do other processing here while EPPI is processing */
}
// Disable the PPI
result = adi_eppi_Enable(hDevice, false);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
/* submit the EPPI buffers */
result = adi_eppi_SubmitBuffer(hDevice, &TxBuffer1, 40);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
// Start the PPI
result = adi_eppi_Enable(hDevice, true);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
}
while(bComplete == false);
// Disable the PPI
result = adi_eppi_Enable(hDevice, false);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
while(1);
/* close the EPPI driver */
result = adi_eppi_Close(hDevice);
if(result != ADI_EPPI_SUCCESS){
printf("Error");
}
return 0;
}

Outcomes