AnsweredAssumed Answered

need help on UART Blackfin 504F

Question asked by sijeo.philip@aydintech.com on Sep 5, 2014
Latest reply on Sep 15, 2014 by CraigG

Hi

 

Hi,

 

I am trying to implement inter processor communication using UART0 of Blackfin 504F , Below is the Callback code for your reference… Interrupt is installed for both receipt and transmit of a byte of data

 

 

 

static void UARTCallback(void* ClientHandle, u32 Event, void* pArg)

 

{

  switch(Event)

{

case ADI_DEV_EVENT_BUFFER_PROCESSED:

if(pArg == &UartInboundBuffer)

{

                UART_COMMAND= (char)UART_RX_DATA;

                 Transmit_Count = 0;

                 Recieve_Count = 0;

                 if(UART_COMMAND == 'M')

                 {

                                 /*UART MEASURE BUFFER*/

                                 UART_Measures[0] = Red_Current_Value;

                                 UART_Measures[1] = Blue_Current_Value;

                                 UART_Measures[2] = Yellow_Current_Value;

                                 UART_Measures[3] = Earth_Current_Value;

                                 UART_Measures[4] = Red_Voltage_Value;

                                 UART_Measures[5] = Blue_Voltage_Value;

                                 UART_Measures[6] = Yellow_Voltage_Value;

                                 UART_Measures[7] = Earth_Voltage_Value;

                                 UART_Measures[8] = R_Phase_Value;

                                 UART_Measures[9] = B_Phase_Value;

                                 UART_Measures[10]= Y_Phase_Value;

                                 UART_Measures[11] =E_Phase_Value;

                                UART_Send = (char*)&UART_Measures[0];

                                 UART_TX_DATA = *UART_Send;

                                 nResult = adi_dev_Write(hUARTHandle, ADI_DEV_1D,(ADI_DEV_BUFFER*)&UartOutboundBuffer);

                    Transmit_Count++;

                 }

     

 

}

  else

  if(pArg == &UartOutboundBuffer)

  {

                *pUART0_LSR = 0x0080;

                 if((UART_COMMAND =='M'))

                 {

 

                            if(Transmit_Count<48)

                                 {

                                                 UART_TX_DATA = *(UART_Send+Transmit_Count);

                                       nResult = adi_dev_Write(hUARTHandle, ADI_DEV_1D,(ADI_DEV_BUFFER*)&UartOutboundBuffer);

                                                Transmit_Count++;

                                 }

                                 else

                     {

                               Transmit_Count=0

 

   nResult = adi_dev_Read(hUARTHandle, ADI_DEV_1D, (ADI_DEV_BUFFER*)&UartInboundBuffer);

                    }

                 }

                                               

 

}

 

break;

          case ADI_UART_EVENT_BREAK_INTERRUPT:

case ADI_UART_EVENT_FRAMING_ERROR:

case ADI_UART_EVENT_PARITY_ERROR:

case ADI_UART_EVENT_OVERRUN_ERROR:

break;

  default:

break;  

 

}

 

               

 

} //END OF UART CALLBACK ROUTINE ------- DEFERRED CALLBACK IMPLEMENTED FOR UART0    

               

 

Currently I am using another controller to send character ‘M’ to Blackfin.. On successful receipt of this character, blackfin loads all the required variables into an Array of Float UART_Measures[0] (as written in the code above) further to which this array is transmitted byte after byte using  character pointer UART_Send… One odd thing happening here is on advancing the pointer array by 16 bytes it starts pointing to the first location of array instead of 16th byte of array.. and transmits the first byte once again… further to which it transmits the 16th byte then 2nd byte , then 17th byte , 3rd byte , 18th byte , 4th byte and so forth…

 

Can you help me understand why this could be happening eventhough I am trying to advance the pointer by 1 byte each time and it works well till the 15th byte…

 

Outcomes