Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem_
Diff: main.cpp
- Revision:
- 0:b76e4ba14765
- Child:
- 1:025596ffc973
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Feb 12 05:10:48 2021 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+
+/*
+ This basic example just shows how to read the ADC internal channels raw values.
+ Please look in the corresponding device reference manual for a complete
+ description of how to make a temperature sensor, VBat or Vref measurement.
+*/
+
+AnalogIn adc_temp(ADC_TEMP);
+AnalogIn adc_vref(ADC_VREF);
+/* UD-GS2 H/W define
+ PIO_SWin PB_4
+ PIO_wkup PA_4
+ PIO_enable PB_0
+ PIO_intout1 PB_2
+ PIO_led PB_5
+ PIO_v20v PC_13
+ PIO_v18v PH_0
+ PIO_intout2 PH_1
+ PIO_spics PB_12
+ PIO_battryMonEn PA_5
+*/
+
+RawSerial pc(PA_9, PA_10,115200); //console UART
+LowPowerTicker interrput;
+SPI STSPI(PB_15, PB_14, PB_13); //mosi,miso,clk
+DigitalOut STSPICS(PB_12);
+DigitalOut led(PB_5);
+
+int main()
+{
+ pc.printf("\nSTM32 ADC internal channels reading example\r\n");
+ while(1) {
+ pc.printf("ADC Temp = %f\r\n", (adc_temp.read()*100));
+ pc.printf("ADC VRef = %f\r\n", adc_vref.read());
+ pc.printf("\033[2A");
+ led = !led;
+ wait(1.0);
+ }
+}