AnsweredAssumed Answered

UART RX Interrupt using ADI drivers BF538F

Question asked by ANANDSM on Dec 18, 2014
Latest reply on Dec 19, 2014 by CraigG

Dear All,

 

I am using BF538F EZ-Kit and trying to configure the UART0 RX interrupt. Could any one let me know how to register the handler using ADI drivers. I tried using the SIC register as mentioned in the code below but could not able to succeed.

 

 

int main(void)

{

  /**

  * Initialise managed drivers and/or services that have been added to

  * the project.

  * @return zero on success

  */

  adi_initComponents();

 

  /* Begin adding your custom code here */

  pwrresult = adi_pwr_Init(

  BF_REFCLK_IN,     // Reference clock for the processor

  BF_MAX_CORECLOCK, // Max Core clock frequency of the processor

  BF_MAX_SYSCLK,  // Max system clock frequency for the processor

  BF_MIN_VCOCLK  // Min VCO frequency operating condition of the PLL

  );

  pwrresult = adi_pwr_SetFreq(CORE_FREQ_SET, SYSCLK_FREQ_SET);

  pwrresult = adi_pwr_GetCoreFreq(&fCoreclk);

  pwrresult = adi_pwr_GetSystemFreq(&fsysclk);

 

  gpioInit();

 

  uart0Init(9600);

 

  result = adi_uart_SubmitTxBuffer(hDevice, buffer, sizeof(buffer));

 

  /* enable the UART transfer */

  result = adi_uart_EnableTx(hDevice, true);

 

  while(bTxFinshed == false)

  {

 

  }

 

  while(1)

  {

  if(bRxDataAvailable == true)

  {

  ioresult = adi_gpio_Set(ADI_GPIO_PORT_C, ADI_GPIO_PIN_7);

  delay(1000000);

  ioresult = adi_gpio_Clear(ADI_GPIO_PORT_C, ADI_GPIO_PIN_7);

  delay(1000000);

  }

}

}

 

void uart0Init(unsigned long baudRate)

{

  /* open the UART driver in Tx mode only */

  result = adi_uart_Open(0, ADI_UART_DIR_BIDIRECTION, driverMemory,

  ADI_UART_BIDIR_INT_MEMORY_SIZE, &hDevice);

  /*

  * Use the driver API's to configure UART

  */

  result = adi_uart_SetConfiguration(hDevice, ADI_UART_NO_PARITY,

  ADI_UART_ONE_STOPBIT, ADI_UART_WORDLEN_8BITS);

 

  result = adi_uart_SetBaudRate(hDevice, baudRate);

 

  result = adi_uart_EnableLoopBack(hDevice, true);

 

  result = adi_uart_EnableDMAMode(hDevice, false);

 

  //result = adi_uart_EnableRx(hDevice, true);

 

  /* register the callback function */

  result = adi_uart_RegisterCallback(hDevice, UARTCallback, (void*)0);

 

  InitUART0Interrupt();

 

  register_handler_ex(ik_ivg14,uartReceiveData,EX_INT_ENABLE);

}

 

void InitUART0Interrupt(void)

{

  *pSIC_IAR0  &= 0xF0FFFFFF;

  *pSIC_IAR0  |= 0x00000000;  // UART Status Interrupt

  *pSIC_IMASK |= UART_ERR_IRQ;

 

 

  *pSIC_IAR1  &= 0xF0FFFFFF;

  *pSIC_IAR1  |= 0x07000000;  // UART Rx Data Interrupt

  *pSIC_IMASK |= DMA6_IRQ;

}

 

In the above code, I tried calling the InitUART0Interrupt(); and register_handler_ex(); at the beginning of the main (before adi_initComponents();) but its throwing CPLB exception when I execute the uart driver APIs

Could you please help me what is the sequence I have to follow and whether APIs are available to achieve this.

For any more information feel free to ask me.

Looking forward to hear from you soon.

Regards

Anand M

Outcomes