Hi,
I am newbie in upp communication, may be anyone can help me to solve my problem. I try to modify upp example from LogicPD for EVMOMAPL138. I want to transmit signal by channel B and receive signal using channel A using digital loopback UPDLB. But the digital loopback didn't work well. Hereby snippet of the code.
uint32_t TEST_adcdac(void)
{
uint32_t retVal = ERR_NO_ERROR;
printf("--------------------------------------------------------------------\r\n");
printf(" UPP / ADC / DAC test\r\n\r\n");
printf("Additional Equipment\r\n");
printf("--------------------\r\n");
printf("- Oscilloscope\r\n\r\n");
printf("- Cable with SMA connector\r\n\r\n");
printf("- Function Generator (passthrough test only)\r\n\r\n");
printf("- 2nd cable with SMA connector (passthrough test only)\r\n\r\n");
printf("Test Description\r\n");
printf("----------------\r\n");
printf("The test will begin producing a 73.2421875KHz sine wave on the analog out line\r\n");
printf("(left SMA connector). After 20 seconds 64 samples will be collected from the ADC (right \r\n");
printf("SMA connector). These samples will be output through the DAC for a period of 20 Seconds. \n\r");
printf("Note that the DAC and ADC are inductively/capacitively coupled with thier connectors.\n\r");
printf("It is strongly reccomended that the signal provided to the ADC have a freqency that is an \n\r");
printf("an integer multiple of 73.2421875KHz and below 1.171875MHz.\n\r");
printf("--------------------------------------------------------------------\r\n\r\n");
//-------------------------------------
// initialize the required bsl modules.
//-------------------------------------
printf("Initialize the Required BSL Modules\r\n");
printf("-----------------------------------\r\n\r\n");
//setup UPP
I2CGPIO_init(I2C_ADDR_GPIO_UI); //IO expander on UI board
I2CGPIO_setOutput(I2C_ADDR_GPIO_UI, I2C_GPIO_UI_SELA, OUTPUT_LOW);
I2CGPIO_setOutput(I2C_ADDR_GPIO_UI, I2C_GPIO_UI_SELB, OUTPUT_LOW);
I2CGPIO_setOutput(I2C_ADDR_GPIO_UI, I2C_GPIO_UI_SELC, OUTPUT_HIGH); //UPP now controls ui databus
//Setup ADC Clock
CDCE913_setOutput(cdce913_output_2, 6); //set to 4.5Mhz
//--------------
// execute test.
//--------------
printf("\r\nExecute Test\r\n");
printf("------------\r\n\r\n");
retVal = executeTest();
if (retVal != ERR_NO_ERROR)
{
printf("ADC/DAC Test FAILED\r\n\r\n");
return (retVal);
}
else
{
printf("ADC/DAC Test completed successfully\r\n\r\n");
}
return retVal;
}
//-----------------------------------------------------------------------------
// Private Function Definitions
//-----------------------------------------------------------------------------
uint32_t executeTest(void)
{
upp_config_t config;
UPXS2_t * UPIS2r = (UPXS2_t *)&(UPP->UPIS2);
UPXS2_t * UPQS2r = (UPXS2_t *)&(UPP->UPQS2);
uint32_t retVal = ERR_NO_ERROR;
uint32_t i;
//UPCTL
config.UPCTL.value=0;
config.UPCTL.bits.IWB = 1; //16 bit interface
config.UPCTL.bits.DPWB = 2; //10 bit data
config.UPCTL.bits.DPFA = 0;
config.UPCTL.bits.DPWA = 2;
config.UPCTL.bits.IWA = 1;
config.UPCTL.bits.CHN = 1; //dual channel mode
config.UPCTL.bits.MODE = 2; //0 all recv, 1 all xmit, 2 a recv b xmit, 3 a xmit b recv
//Channel A ADC, Channel B DAC
//UPICR
config.UPICR.value=0;
config.UPICR.bits.CLKDIVB = 15; //Set DAC sampling freqency at 75/16 Mhz (4.6875MHz)
//UPIVR
config.UPIVR.value=0;
config.UPIVR.bits.VALB = 0x1000;
config.UPIVR.bits.VALA = 0x0000;
//UPTCR
config.UPTCR.value=0; //all values 0 for 64byte DMA bursts read / write
//UPDLB
config.UPDLB.value=0; //no loopback
config.UPDLB.bits.BA = 1;
config.UPDLB.bits.AB = 0;
//UPIES
config.UPIES.value=0; //dont enable any interrupts
//UPPCR
config.UPPCR.value = 0;
config.UPPCR.bits.EN = 1; //enable uPP
config.UPPCR.bits.RTEMU = 1; //allow emulator use
config.UPPCR.bits.SOFT = 1; //allow emulation
UPP_init(&config);
printf("---Generating 73.2421875KHz sine wave for 20 seconds---\r\n\r\n");
for(i = 1; i < 1464843; i++)
{
UPP->UPQD0 = (uint32_t)&xmit_buffer;//add next DMA transfer
UPP->UPQD1 = 0x00010080; //1 lines 128 bytes per line
UPP->UPQD2 = 0x00000080; //no offset between lines
while(UPQS2r->bits.PEND == 1){};
}
printf("---Collecting 64 samples from ADC---\r\n");
UPP->UPID0 = (uint32_t)&recv_buffer;//add next DMA transfer
UPP->UPID1 = 0x00010080; //1 lines 128 bytes per line
UPP->UPID2 = 0x00000080; //no offset between lines
while(UPIS2r->bits.PEND == 1){};
printf("---Displaying collected samples---\r\n");
for(i = 0; i < 1464843; i++)
{
UPP->UPQD0 = (uint32_t)&recv_buffer;//add next DMA transfer
UPP->UPQD1 = 0x00010080; //1 lines 128 bytes per line
UPP->UPQD2 = 0x00000080; //no offset between lines
while(UPQS2r->bits.PEND == 1){}; //wait for tx transfer to complete
}
return retVal;
}