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.

writing to a PIP object

I am using a C6726 and DSPBios with CCS5. My problem is I cannot get CCS5 to compile when I try to use a pointer to the PIP_getWriterAddr() function as the basis of where to copy data to. The examples as shown in the literature will not compile either.

 

              if (PIP_getWriterNumFrames(&inputpipe) > 0)     //how many frames are available
			{
		        PIP_alloc(&inputpipe);  /* allocate an empty frame */
		        addr = PIP_getWriterAddr(&inputpipe);
		        size = PIP_getWriterSize(&inputpipe);
		        if(size > 0x10){PIP_setWriterSize(&inputpipe, 0x10);} //set frame to 1 word size 16bits
			addr = McASP0ptr[RBUF0];
		        //enter data in the frame
		        //sample[]   run untill newSamplecount = 0

		        PIP_put(&inputpipe); //release frame to pipe
		        newSamplecount--;    //data is down pipe, decrement counter
		}

In particular the line "addr = McASP0ptr[RBUF0]" causes the error--  #76 operand of "*" must be a pointer

Started with "*addr = McASP0ptr[RBUF0]" thinking it should allow a write to the address referenced by addr but it give another error. I also tried to do a direct cut and paste of the example code

Void copy(HST_Obj *input, HST_Obj *output)
{
    PIP_Obj     *in, *out;
    Uns         *src, *dst;
    Uns         size;
    in = HST_getpipe(input);
    out = HST_getpipe(output);
    if (PIP_getReaderNumFrames(in) == 0 || 
        PIP_getWriterNumFrames(out) == 0) {
        error;
    }
    /* get input data and allocate output frame */
    PIP_get(in);
    PIP_alloc(out);
    /* copy input data to output frame */
    src = PIP_getReaderAddr(in);
    dst = PIP_getWriterAddr(out);
    size = PIP_getReaderSize(in);
    PIP_setWriterSize(out, size);
    for (; size > 0; size--) {
        *dst++ = *src++;
    }
    /* output copied data and free input frame */
    PIP_put(out);
    PIP_free(in);
}

In this case CCS5 says that a pointer like "*scr" and "*dst" cannot be initialized with Uns.

  • Hi Joshua,

    Joshua Hinton said:

     

                  if (PIP_getWriterNumFrames(&inputpipe) > 0)     //how many frames are available
    			{
    		        PIP_alloc(&inputpipe);  /* allocate an empty frame */
    		        addr = PIP_getWriterAddr(&inputpipe);
    		        size = PIP_getWriterSize(&inputpipe);
    		        if(size > 0x10){PIP_setWriterSize(&inputpipe, 0x10);} //set frame to 1 word size 16bits
    			addr = McASP0ptr[RBUF0];
    		        //enter data in the frame
    		        //sample[]   run untill newSamplecount = 0
    
    		        PIP_put(&inputpipe); //release frame to pipe
    		        newSamplecount--;    //data is down pipe, decrement counter
    		}

    In particular the line "addr = McASP0ptr[RBUF0]" causes the error--  #76 operand of "*" must be a pointer

    Can you share the entire function (with addr, size & McASP0Ptr[] declarations) and the compiler version you are using ?

    Best,

    Ashish

  • After allowing CCS to do its update it will now compile. I did have to add a c++ mem.h lib and use memcpy to get it to work.

    volatile unsigned int *McASP_RBUF0 = (unsigned int *)0x44000280;
    
    
    while(PIP_getReaderNumFrames(&inputpipe) > 0)
    	{
    		if(SEM_pendBinary(&sampleDataReady, 0) == true) //used to protect against dual "get" calls from HWI and this Task
    		{
    			PIP_get(&inputpipe);
    			addr = PIP_getReaderAddr(&inputpipe);
    			size = PIP_getReaderSize(&inputpipe);
    			if(size < 16){LOG_printf(&trace, "ERROR: frame size < 16bits \n");}
    
    			memcpy(tempBuff, addr, 2);
    			PIP_free(&inputpipe);


    void

    readNextSample()  //make a HWI function call

    {

    Uns size;
    
    
    
    
    //check read buffer
    
    
    
    
    if(SEM_pendBinary(&sampleDataReady, 0) == true) //use counter to avoid missing samples
    
    {
    
    if (PIP_getWriterNumFrames(&inputpipe) > 0)     //how many frames are available
    
    {
    
    PIP_alloc(&inputpipe);                    // allocate an empty frame to write in
    
    
    
    
    Ptr addr = PIP_getWriterAddr(&inputpipe);  //get address of empty frame
    
    size = PIP_getWriterSize(&inputpipe);    
    
    //find size of empty frame
    
    
    
    
    if(size > 0x10){PIP_setWriterSize(&inputpipe, 0x10);} //set frame to 2 word size 32bits
    
    
    
    
    unsigned int tempBuff[1];
    
    tempBuff[0] = *McASP_RBUF0;
    
    memcpy(addr, tempBuff, 2);
    
    PIP_put(&inputpipe); //release frame to pipe
    
    }
    
    else //exit function with ERROR
    
    {
    
    LOG_printf(&trace, "ERROR: new sample function: no empty frames  \n");
    
    
    
    
    SEM_postBinary(&sampleDataReady);
    
    
    
    
    return;
    
    }
    
    }
    
    //end if
    
    
    
    
    SEM_postBinary(&sampleDataReady);  //release semaphore at end of function
    
    }
    
    //end of read next sample