This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ADC Boundary Interrupt problem

Hi,
I've got a strange problem using ADC boundary interrupts in conjunction with UART baud rate generator.

If I disable the baud rate generator, my ADC boundary interrupts occur perfectly when the AD0DAT0 go above or below the set boundary values.

If I enable the baud rate generator for UART, my ADC interrupt keeps occurring continuously, all the time irrespective of the boundary values.
The same problem occurs when I use Timer1 for UART instead of the baud rate generator.

Has anyone faced this problem? Any suggestions will be appreciated.

Thanks and Regards,
Vish P.

Device: LPC935/936.
CPU Clock Freq: 1.8432 MHz.
UART baud rate: 9600.

void ADC_Init(void)
{
  ADMODB = 0x00;
 /*******************************************************************************
  * Set adc0 channel 0 pins to input only (disables digital output)                             *
  *******************************************************************************/
  P1M1 |= 0x80;
  P1M2 &= ~0x80;

 /*******************************************************************************
  * Set adc0 channel 1 pins to input only (disables digital output)                             *
  *******************************************************************************/
  P0M1 |= 0x01;
  P0M2 &= ~0x01;

 /*******************************************************************************
  * Disable dac0                                                                                                                                *
  *******************************************************************************/
  ADMODB &= ~0x04;

 /*******************************************************************************
  * Set boundaries                                                                                                                              *
  *******************************************************************************/
  AD0BH = 0xC0;
  AD0BL = 0x40;

 /*******************************************************************************
  * Use boundary limits only for channel 0                                                                              *
  *******************************************************************************/
  ADMODB &= ~0x01;

 /*******************************************************************************
  * Enable Boundry Interrupt, Enable ADC0. Mode: Immediate Start.                               *
  *******************************************************************************/
  ADCON0 = (ENBI0 | ENADC0 | ADCS0);

 /*******************************************************************************
  * Set ISR Priority to 0                                                                                                               *
  *******************************************************************************/
  IP1 &= 0x7F;
  IP1H &= 0x7F;

 /*******************************************************************************
  * Set Mode to Auto scan continuous conversion for AD0                                                 *
  *******************************************************************************/
  ADMODA = (BURST0);

 /*******************************************************************************
  * Select channels                                                                                                                             *
  *******************************************************************************/
  ADINS = (ADC0_CHANNEL1|ADC0_CHANNEL0);

 /*******************************************************************************
  * Enable ADC Interrupt                                                                                                                *
  *******************************************************************************/
  EAD = 1;
}

void ADC_ISR(void) interrupt 14 using 3
{
  if (ADMODA & 0x08)
  {
    ADMODA &= ~0x08;
  }
}

void UART_Init(void)
{
 /*******************************************************************************
  * Configure UART      9600 running at run at 1.8432MHz clock , clear SMOD0            *
  *******************************************************************************/
  PCON &= ~0x40;
  SCON = 0x50;

 /*******************************************************************************
  * Set or Clear SMOD1                                                                                                                  *
  *******************************************************************************/
  PCON &= 0x7f;
  PCON |= (0 << 8);
  SSTAT = 0x00;

 /*******************************************************************************
  * Configure Baud Rate Generator                                                                                               *
  *******************************************************************************/
  BRGCON = 0x00;
  BRGR0 = 0xB0;
  BRGR1 = 0x00;
  BRGCON = 0x03;

 /*******************************************************************************
  * TxD = Push-Pull, RxD = Quasi-Bidirectional and write high on the pins               *
  *******************************************************************************/
  P1M1 &= 0xFC;
  P1M2 |= 0x01;
  P1 |= 3;

 /*******************************************************************************
  * Initially not busy                                                                                                                  *
  *******************************************************************************/
  mtxbusy = 0;

 /*******************************************************************************
  * Set ISR Priority to Level 0                                                                                                 *
  *******************************************************************************/
  IP0 &= 0xEF;
  IP0H &= 0xEF;


 /*******************************************************************************
  * Enable UART Interrupt                                                                                                               *
  *******************************************************************************/
  ES = 1;
}

0