Skip to main content
deleted 111 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
volatile unsigned long value;

void setup() 
{
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2     |
  ADC->ADC_MR &= 0b11111111000000001111111100000000;
  ADC->ADC_MR |= 0b00000000000100100000000000100000;0b00000000000100100000000000000000; //software trigger, hi res, no sleep, not free running
  ADC->ADC_IER = 0b100; //enable interrupt
  ADC->ADC_IMR = 0b100; //enable interrupt in mask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  while (!(ADC->ADC_ISR & 0b100)); //wait for conversion to end 
 
  for (int i = 0; i <= 15; i++)
 { 
    value = ADC->ADC_CDR[i]; //read conversion data for channelall 2channels
    Serial.println(value);    
 }
 
 Serial.println();
 Serial.println();
 Serial.println();
 
 delay(3000);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048. Here's the serial output of all 15 channels, now in 12 bit mode:

0
0
20484095
0
0
0
0
0
0
0
0
0
0
0
0
0



0
0
20484095
0
0
0
0
0
0
0
0
0
0
0
0
0
volatile unsigned long value;

void setup() 
{
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2
  ADC->ADC_MR &= 0b11111111000000001111111100000000;
  ADC->ADC_MR |= 0b00000000000100100000000000100000; //software trigger, hi res, no sleep, not free running
  ADC->ADC_IER = 0b100; //enable interrupt
  ADC->ADC_IMR = 0b100; //enable interrupt in mask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  while (!(ADC->ADC_ISR & 0b100)); //wait for conversion to end 
 
  for (int i = 0; i <= 15; i++)
 { 
    value = ADC->ADC_CDR[i]; //read conversion data for channel 2
    Serial.println(value);    
 }
 
 Serial.println();
 Serial.println();
 Serial.println();
 
 delay(3000);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048. Here's the serial output of all 15 channels:

0
0
2048
0
0
0
0
0
0
0
0
0
0
0
0
0



0
0
2048
0
0
0
0
0
0
0
0
0
0
0
0
0
volatile unsigned long value;

void setup() 
{
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2     |
  ADC->ADC_MR &= 0b11111111000000001111111100000000;
  ADC->ADC_MR |= 0b00000000000100100000000000000000; //software trigger, hi res, no sleep, not free running
  ADC->ADC_IER = 0b100; //enable interrupt
  ADC->ADC_IMR = 0b100; //enable interrupt in mask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  while (!(ADC->ADC_ISR & 0b100)); //wait for conversion to end 
 
  for (int i = 0; i <= 15; i++)
 { 
    value = ADC->ADC_CDR[i]; //read conversion data for all channels
    Serial.println(value);    
 }
 
 Serial.println();
 Serial.println();
 Serial.println();
 
 delay(3000);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048. Here's the serial output of all 15 channels, now in 12 bit mode:

0
0
4095
0
0
0
0
0
0
0
0
0
0
0
0
0



0
0
4095
0
0
0
0
0
0
0
0
0
0
0
0
0
deleted 102 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
volatile unsigned long value;

void setup() 
{
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2
  ADC->ADC_MR &= 0b11111111000000001111111100000000;
  ADC->ADC_MR |= 0b00000000000100100000000000100000; //software trigger, hi res, no sleep, not free running
  ADC->ADC_IER = 0b100; //enable interrupt
  ADC->ADC_IMR = 0b100; //enable interrupt in mask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  while (!(ADC->ADC_ISR & 0b100)); //wait for conversion to end  
 
  unsignedfor long(int i = 0; i <= 15; i++)
 { 
    value = ADC->ADC_CDR[2];>ADC_CDR[i]; //read conversion data for channel 2
  
   Serial.println(value);    
 }
 
 Serial.println();
 Serial.println();
 Serial.println();
 
 delay(3000);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048. Here's the serial output of all 15 channels:

0
0
2048
0
0
0
0
0
0
0
0
0
0
0
0
0



0
0
2048
0
0
0
0
0
0
0
0
0
0
0
0
0
void setup() 
{
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2
  ADC->ADC_MR &= 0b11111111000000001111111100000000;
  ADC->ADC_MR |= 0b00000000000100100000000000100000; //software trigger, hi res, no sleep, not free running
  ADC->ADC_IER = 0b100; //enable interrupt
  ADC->ADC_IMR = 0b100; //enable interrupt in mask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  while (!(ADC->ADC_ISR & 0b100)); //wait for conversion to end  
  unsigned long value = ADC->ADC_CDR[2]; //read conversion data for channel 2
  
   Serial.println(value);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048.

volatile unsigned long value;

void setup() 
{
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2
  ADC->ADC_MR &= 0b11111111000000001111111100000000;
  ADC->ADC_MR |= 0b00000000000100100000000000100000; //software trigger, hi res, no sleep, not free running
  ADC->ADC_IER = 0b100; //enable interrupt
  ADC->ADC_IMR = 0b100; //enable interrupt in mask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  while (!(ADC->ADC_ISR & 0b100)); //wait for conversion to end  
 
  for (int i = 0; i <= 15; i++)
 { 
    value = ADC->ADC_CDR[i]; //read conversion data for channel 2
    Serial.println(value);    
 }
 
 Serial.println();
 Serial.println();
 Serial.println();
 
 delay(3000);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048. Here's the serial output of all 15 channels:

0
0
2048
0
0
0
0
0
0
0
0
0
0
0
0
0



0
0
2048
0
0
0
0
0
0
0
0
0
0
0
0
0
deleted 102 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
void setup() 
{
  //pinADC setup
  PIOAADC->PIO_PER>ADC_WPMR =&= PIO_PA4;0xFFFE; //enabledisable input/outputwrite pinprotect
  PIOAADC->PIO_ODR>ADC_CHER = PIO_PA4;0b100; //outputEnable disableAD2
  PIOAADC->PIO_PUDR = PIO_PA4;  //disable pull up resistor
  
 >ADC_MR //ADC&= setup0b11111111000000001111111100000000;
  ADC->ADC_WPMR>ADC_MR &=|= 0xFFFE;0b00000000000100100000000000100000; //disablesoftware writetrigger, protect
hi res, ADC->ADC_CHERno =sleep, 0b100;not //Enablefree AD2running
  ADC->ADC_MR>ADC_IER |== 0b10000000;0b100; //free runningenable modeinterrupt
  ADC->ADC_MR>ADC_IMR &== 0b11011111;0b100; //ensureenable notinterrupt in safe modemask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  delaywhile (100!(ADC->ADC_ISR & 0b100));
  //wait for conversion to end  
  intunsigned long value = ADC->ADC_CDR[2]; //read conversion data for channel 2
  
  Serial.println(value);
  
  delay(100);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 0xFFF.

EDIT2: I appears that the ADC_ISR register shows that no conversions are completing2048.

void setup() 
{
  //pin setup
  PIOA->PIO_PER = PIO_PA4; //enable input/output pin
  PIOA->PIO_ODR = PIO_PA4; //output disable
  PIOA->PIO_PUDR = PIO_PA4;  //disable pull up resistor
  
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2
  ADC->ADC_MR |= 0b10000000; //free running mode
  ADC->ADC_MR &= 0b11011111; //ensure not in safe mode
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  delay (100);
   
  int value = ADC->ADC_CDR[2]; //read conversion data for channel 2
  Serial.println(value);
  
  delay(100);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled, yet the conversion data is always 0xFFF.

EDIT2: I appears that the ADC_ISR register shows that no conversions are completing.

void setup() 
{
  //ADC setup
  ADC->ADC_WPMR &= 0xFFFE; //disable write protect
  ADC->ADC_CHER = 0b100; //Enable AD2
  ADC->ADC_MR &= 0b11111111000000001111111100000000;
  ADC->ADC_MR |= 0b00000000000100100000000000100000; //software trigger, hi res, no sleep, not free running
  ADC->ADC_IER = 0b100; //enable interrupt
  ADC->ADC_IMR = 0b100; //enable interrupt in mask
  
  ADC->ADC_CR |= 0b10; //start first conversion
  Serial.begin(9600);
}

void loop() 
{
  ADC->ADC_CR |= 0b10; //start conversion
  while (!(ADC->ADC_ISR & 0b100)); //wait for conversion to end  
  unsigned long value = ADC->ADC_CDR[2]; //read conversion data for channel 2
  
  Serial.println(value);
}

Just doesn't seem to be doing anything. ADC_CHSR (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048.

added 90 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
Loading
added 1087 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
Loading
added 2 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
Loading
added 183 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
Loading
added 36 characters in body
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
Loading
Source Link
Littlegator
  • 121
  • 1
  • 1
  • 4
Loading