Comments (5)
Hi @claudiaAl, this is difficult to answer since we can't see most of the reads/writes you're doing to ADC_CTRL. Can you please post a complete, verifiable example? i.e. an example that I can copy/paste into my own IDE and run myself.
from arduinocore-arc32.
Absolutely! My apologies :-)
#include <CurieTimerOne.h>
#include <SPI.h>
#define ATP_BLE_INT 5
uint32_t creg, saved;
void adc_normal_wo_calib_REFERENCE(){
/* perform power up to "Normal mode w/o calibration" cycle if not already there */
if( (creg & ADC_MODE_MASK) != ADC_NORMAL_WO_CALIB){
/* Protect AR_IO_CREG_MST0_CTRL using lock and unlock of interruptions */
saved = interrupt_lock();
/* Read current CREG master */
creg = READ_ARC_REG(AR_IO_CREG_MST0_CTRL);
creg &= ~(ADC_MODE_MASK);
/* request ADC to go to Standby mode */
creg |= ADC_STANDBY | ADC_CLOCK_GATE;
WRITE_ARC_REG(creg, AR_IO_CREG_MST0_CTRL);
interrupt_unlock(saved);
/* Poll CREG Slave 0 for Power Mode status = requested status */
while ( (creg = READ_ARC_REG(AR_IO_CREG_SLV0_OBSR) & 0x8) == 0);
/* Protect AR_IO_CREG_MST0_CTRL using lock and unlock of interruptions */
saved = interrupt_lock();
creg = READ_ARC_REG(AR_IO_CREG_MST0_CTRL);
creg &= ~(ADC_MODE_MASK);
/* request ADC to go to Normal mode w/o calibration */
creg |= ADC_NORMAL_WO_CALIB | ADC_CLOCK_GATE;
WRITE_ARC_REG(creg, AR_IO_CREG_MST0_CTRL);
interrupt_unlock(saved);
/* Poll CREG Slave 0 for Power Mode status = requested status */
while ( ((creg = READ_ARC_REG(AR_IO_CREG_SLV0_OBSR)) & 0x8) == 0);
}
WRITE_ARC_REG(ADC_CLK_ENABLE | ADC_INT_DSB, ADC_CTRL);
WRITE_ARC_REG(ADC_CONFIG_SETUP, ADC_SET);
WRITE_ARC_REG(ADC_CLOCK_RATIO & ADC_CLK_RATIO_MASK, ADC_DIVSEQSTAT);
Serial.print("ADC_CTRL after write: ");
Serial.print(ADC_CTRL, BIN);
Serial.println();
creg = READ_ARC_REG(ADC_CTRL);
Serial.print("ADC_CTRL in CREG after write: ");
Serial.print(ADC_CTRL, BIN);
Serial.println();
}
void disableADC(){
creg = READ_ARC_REG(ADC_CTRL);
Serial.print("ADC_CTRL reg before disabling ADC ");
Serial.print(creg, BIN);
Serial.println();
saved = interrupt_lock();
creg &= ~(1 << 2);
creg |= READ_ARC_REG(ADC_CTRL);
WRITE_ARC_REG(creg, ADC_CTRL);
interrupt_unlock(saved);
creg = READ_ARC_REG(ADC_CTRL);
Serial.print("ADC_CTRL reg after disabling ADC ");
Serial.print(creg, BIN);
Serial.println();
}
void setup() {
Serial.begin(115200);
while(!Serial);
adc_normal_wo_calib_REFERENCE();
creg = READ_ARC_REG(ADC_CTRL);
Serial.print("In SETUP ADC_CTRL after norm wo calib ");
Serial.print(creg, BIN);
Serial.println();
disableADC();
creg = READ_ARC_REG(ADC_CTRL);
Serial.print("In SETUP ADC_CTRL after disableADC() ");
Serial.print(creg, BIN);
Serial.println();
}
void loop() {
// put your main code here, to run repeatedly:
}
I don't think my logic in disableADC() is correct yet, but I'm really looking at the difference in the register going from the adc_normal_wo_calib_REFERENCE() function back to setup()
Thanks in advance!
from arduinocore-arc32.
ADC_CTRL is a #define for the memory address of the ADC_CTRL register.
#define ADC_CTRL (0x80015003)
So when you do this;
Serial.print(ADC_CTRL, BIN);
You're not actually printing out the value stored at that address, you're printing the address itself. It's the same as doing this:
Serial.print(0x80015003, BIN);
from arduinocore-arc32.
Arg dumb mistake! Thank you sir :-)
from arduinocore-arc32.
No problem.
from arduinocore-arc32.
Related Issues (20)
- Error compiling for board Arduino/Genuino 101. HOT 7
- Peripheral not connectable when broadcasting characteristic value
- Incorrect capitalization of true in CurieIMU documentation HOT 3
- some EEPROM.CPP ERROR HOT 1
- SPI.beginTransaction allows SPISettings faster than 8 MHz
- Cannot discover attributes HOT 1
- Limited error messages, when selecting the wrong COM port
- How to using UART ISR ?
- [Urgent][Stuck Problem] BLE setValue in callback function!
- Can't send BLE data less than 25ms? HOT 3
- Crashing when three or more characteristics are updated every 30ms? HOT 1
- CurieBLE - BLECommon dosen't existe .. HOT 2
- CurieBLE for HM-11
- Should extra_flags be empty in platform.txt? HOT 1
- SoftwareSerial core library
- IPAddress missing definition of operator!=()
- When I try to upload a simple sketch to the Arduino 101, I get the following error on Mac M1 (macOS Monterey) HOT 3
- No tag for 2.0.6 release
- error: #error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor." #error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor." HOT 2
- Placing the breadboard with BMI160 to horizontally(remapping axis) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinocore-arc32.