LPC1115 freezes while reading ADC

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC1115 freezes while reading ADC

696件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by audriusmerfeldas on Mon Oct 19 14:45:46 MST 2015
My LPC1115 freezes at the line:
"while ((LPC_ADC->DR[1] < 0x7FFFFFFF));   //wait for "done" bit to be set" or sometimes on:
"while ((LPC_ADC->DR[2] < 0x7FFFFFFF));   //wait for "done" bit to be set".

Any advices?

Please find the code bellow:

//SET UP THE ADC
  LPC_SYSCON->PDRUNCFG        &= ~(0x1<<4);  //power the ADC
  LPC_SYSCON->SYSAHBCLKCTRL   |= (1<<13);    //enable clock for ADC
  LPC_IOCON->R_PIO0_11        &= 0xFFFFFF78; //clear FUNC field for pin 32, set to analog input
  LPC_IOCON->R_PIO1_0         &= ~(0x97);    //clear FUNC field for pin 33, set to analog input
  LPC_IOCON->R_PIO1_1         &= ~(0x97);    //clear FUNC field for pin 34, set to analog input
  LPC_IOCON->R_PIO0_11        |= (1<<1);     //set to ADC mode for pin 32
  LPC_IOCON->R_PIO1_0        |= (1<<1);     //set to ADC mode for pin 33
  LPC_IOCON->R_PIO1_1        |= (1<<1);     //set to ADC mode for pin 34
  LPC_IOCON->R_PIO0_11         &= ~(0x10);    //turn off pull up
  LPC_IOCON->R_PIO1_0          &= ~(0x10);    //turn off pull up
  LPC_IOCON->R_PIO1_1          &= ~(0x10);    //turn off pull up

  while (1)                                   // Loop forever
  {
      LPC_ADC->CR     = 0x0B01;      //select ADC channel AD0 (pin 32), set up clock
      LPC_ADC->CR     |= (1<<24);    //start conversion by setting "Start Conversion Now" bit
      while ((LPC_ADC->DR[0] < 0x7FFFFFFF));   //wait for "done" bit to be set
      x=(LPC_ADC->DR[0]);

      LPC_ADC->CR     = 0x0B02;      //select ADC channel AD1 (pin 33), set up clock
      LPC_ADC->CR     |= (1<<24);    //start conversion by setting "Start Conversion Now" bit
      while ((LPC_ADC->DR[1] < 0x7FFFFFFF));   //wait for "done" bit to be set
      y=(LPC_ADC->DR[1]);

      LPC_ADC->CR     = 0x0B04;      //select ADC channel AD2 (pin 34), set up clock
      LPC_ADC->CR     |= (1<<24);    //start conversion by setting "Start Conversion Now" bit
      while ((LPC_ADC->DR[2] < 0x7FFFFFFF));   //wait for "done" bit to be set
      z=(LPC_ADC->DR[2]);
ラベル(1)
0 件の賞賛
返信
1 返信

644件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by audriusmerfeldas on Mon Oct 19 23:19:46 MST 2015
It doesn't freeze immediately, but after 8 - 15s of continuous operation.
0 件の賞賛
返信