Skip to content

Commit b2c4062

Browse files
committed
remove CANTX / CANRX from audio guide
the CANRX and CANTX pins are not attached to the ADC, and they were incorrectly documented, likely due to previous boards with form factor having these pins as A14/15
1 parent c785595 commit b2c4062

File tree

1 file changed

+48
-48
lines changed
  • content/hardware/10.mega/boards/giga-r1-wifi/tutorials/giga-audio

1 file changed

+48
-48
lines changed

content/hardware/10.mega/boards/giga-r1-wifi/tutorials/giga-audio/content.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Guide to GIGA R1 Advanced ADC/DAC and Audio Features
3-
description: 'Learn how to use the ADC/DAC features, along with useful examples on how to generate waveforms and play audio from a file.'
3+
description: "Learn how to use the ADC/DAC features, along with useful examples on how to generate waveforms and play audio from a file."
44
author: José Bagur, Taddy Chung & Karl Söderby
55
hardware:
66
- hardware/10.mega/boards/giga-r1-wifi
@@ -11,15 +11,16 @@ software:
1111
tags: [ADC, DAC, Audio, USB]
1212
---
1313

14-
In the GIGA R1, you can find the powerful STM32H747XI, a dual-core 32-bit Arm® Cortex® microcontroller from STMicroelectronics; this is the same microcontroller found in the [Portenta H7](/hardware/portenta-h7) board.
14+
In the GIGA R1, you can find the powerful STM32H747XI, a dual-core 32-bit Arm® Cortex® microcontroller from STMicroelectronics; this is the same microcontroller found in the [Portenta H7](/hardware/portenta-h7) board.
1515

1616
In this guide, we will focus on the advanced ADC/DAC features, utilizing the [Arduino_AdvancedAnalog](https://github.com/arduino-libraries/Arduino_AdvancedAnalog) library. The examples found in this guide can be used to:
17-
- Set up and read ADCs with specific parameters (resolution, sample rate, number of samples per channel, queue depth).
18-
- Set up and write to a DAC channel with specific parameters (resolution, frequency, number of samples per channel, queue depth).
17+
18+
- Set up and read ADCs with specific parameters (resolution, sample rate, number of samples per channel, queue depth).
19+
- Set up and write to a DAC channel with specific parameters (resolution, frequency, number of samples per channel, queue depth).
1920
- Generate specific waveforms through input via serial commands (triangle, square, sine, sawtooth waves) as well as adjusting the frequency.
2021
- Read and play audio files (`.wav`) from a USB stick (connected to USB-A) to a speaker, using the audio jack.
2122

22-
***Important note: the GIGA R1 does NOT have an amplifying circuit onboard. Connecting speakers that does not have an amplifier can damage the DAC and the board itself.***
23+
**_Important note: the GIGA R1 does NOT have an amplifying circuit onboard. Connecting speakers that does not have an amplifier can damage the DAC and the board itself._**
2324

2425
## Hardware & Software Needed
2526

@@ -45,34 +46,32 @@ The image below shows the position of the audio pins and connectors of the GIGA
4546

4647
![ADC/DAC pins and connectors of the GIGA R1](assets/audio-pins.png)
4748

48-
The table below explains the full functionality of the listed on it; notice that some pins have more than one functionality, such as `DAC0`, `DAC1`, `CANRX`, and `CANTX`:
49-
50-
| Pin | Functionality |
51-
|:-----:|:--------------:|
52-
| A0 | ADC |
53-
| A1 | ADC |
54-
| A2 | ADC |
55-
| A3 | ADC |
56-
| A4 | ADC |
57-
| A5 | ADC |
58-
| A6 | ADC |
59-
| A7 | ADC |
60-
| A8 | ADC |
61-
| A9 | ADC |
62-
| A10 | ADC |
63-
| A11 | ADC |
64-
| DAC0 | ADC and DAC |
65-
| DAC1 | ADC and DAC |
66-
| CANRX | ADC and CAN RX |
67-
| CANTX | ADC and CAN TX |
49+
The table below explains the full functionality of the listed on it; notice that `A12` and `A13` can be used as DACs (`DAC0`, `DAC1`).
50+
51+
| Pin | Functionality |
52+
| :--------: | :------------: |
53+
| A0 | ADC |
54+
| A1 | ADC |
55+
| A2 | ADC |
56+
| A3 | ADC |
57+
| A4 | ADC |
58+
| A5 | ADC |
59+
| A6 | ADC |
60+
| A7 | ADC |
61+
| A8 | ADC |
62+
| A9 | ADC |
63+
| A10 | ADC |
64+
| A11 | ADC |
65+
| A12 / DAC0 | ADC and DAC |
66+
| A13 / DAC1 | ADC and DAC |
6867

6968
Pins `A7`, `DAC0`, and `DAC1` can also be accessed via the built-in TRRS 3.5mm jack. `DAC0` is connected to ring 1 (right channel), `DAC1` is connected to the tip (left channel), and `A7` is connected to ring 2 (microphone) of the jack, as shown in the schematic below:
7069

7170
![GIGA R1 TRRS 3.5mm jack schematic](assets/jack-schematic-1.png)
7271

7372
## Analog-to-Digital Converter (ADC)
7473

75-
An analog-to-digital converter (ADC) is a device that converts an analog voltage, or signal, into digital data. The GIGA R1 microcontroller, the STM32H747XI, embeds three ADCs whose resolution can be configured to 8, 10, 12, 14, or 16 bits. Each ADC shares up to 20 external channels that can be accessed in the GIGA R1 board through pins `A0`, `A1`, `A2`, `A3`, `A4`, `A5`, `A6`, `A7`, `A8`, `A9`, `A10`, and `A11`; pins `DAC0`, `DAC1`, `CANRX`, and `CANTX` can also be used as ADCs.
74+
An analog-to-digital converter (ADC) is a device that converts an analog voltage, or signal, into digital data. The GIGA R1 microcontroller, the STM32H747XI, embeds three ADCs whose resolution can be configured to 8, 10, 12, 14, or 16 bits. Each ADC shares up to 20 external channels that can be accessed in the GIGA R1 board through pins `A0`, `A1`, `A2`, `A3`, `A4`, `A5`, `A6`, `A7`, `A8`, `A9`, `A10`, and `A11`; pins `DAC0`, `DAC1` can also be used as ADCs.
7675

7776
![ADC pins of the GIGA R1](assets/adcs.png)
7877

@@ -171,7 +170,7 @@ A digital-to-analog converter (DAC) is a device that has a function opposite to
171170

172171
- 8-bit or 12-bit monotonic output
173172
- Left or right data alignment in 12-bit mode
174-
- Dual DAC channel independent or simultaneous conversions
173+
- Dual DAC channel independent or simultaneous conversions
175174
- DMA capability for each channel
176175
- External triggers for conversion
177176
- Input voltage reference or internal voltage reference
@@ -262,15 +261,15 @@ void setup() {
262261
263262
void dac_output_sq(AdvancedDAC &dac_out) {
264263
if (dac_out.available()) {
265-
264+
266265
// Get a free buffer for writing.
267266
SampleBuffer buf = dac_out.dequeue();
268-
267+
269268
// Write data to buffer.
270269
for (int i=0; i<buf.size(); i++) {
271270
buf.data()[i] = (i % 2 == 0) ? 0: 0xfff;
272271
}
273-
272+
274273
// Write the buffer to DAC.
275274
dac_out.write(buf);
276275
}
@@ -350,8 +349,8 @@ AdvancedDAC dac0(A12);
350349
uint8_t SAMPLES_BUFFER[N_SAMPLES];
351350
size_t dac_frequency = DEFAULT_FREQUENCY;
352351
353-
void generate_waveform(int cmd)
354-
{
352+
void generate_waveform(int cmd)
353+
{
355354
switch (cmd) {
356355
case 't':
357356
// Triangle wave
@@ -388,29 +387,29 @@ void generate_waveform(int cmd)
388387
case '+':
389388
case '-':
390389
Serial.print("Current frequency: ");
391-
390+
392391
if (cmd == '+' && dac_frequency < 64000) {
393392
dac_frequency *= 2;
394393
} else if (cmd == '-' && dac_frequency > 1000) {
395394
dac_frequency /= 2;
396395
} else {
397396
break;
398397
}
399-
398+
400399
dac0.stop();
401400
delay(500);
402401
if (!dac0.begin(AN_RESOLUTION_8, dac_frequency * N_SAMPLES, N_SAMPLES, 32)) {
403402
Serial.println("Failed to start DAC1 !");
404403
}
405404
delay(500);
406405
break;
407-
406+
408407
default:
409408
Serial.print("Unknown command ");
410409
Serial.println((char) cmd);
411410
return;
412411
}
413-
412+
414413
Serial.print(dac_frequency/1000);
415414
Serial.println("KHz");
416415
}
@@ -422,17 +421,17 @@ void setup() {
422421
423422
}
424423
425-
424+
426425
Serial.println("Enter a command:");
427426
Serial.println("t: Triangle wave");
428427
Serial.println("q: Square wave");
429428
Serial.println("s: Sine wave");
430429
Serial.println("r: Sawtooth wave");
431430
Serial.println("+: Increase frequency");
432431
Serial.println("-: Decrease frequency");
433-
432+
434433
generate_waveform('s');
435-
434+
436435
// DAC initialization
437436
if (!dac0.begin(AN_RESOLUTION_8, DEFAULT_FREQUENCY * N_SAMPLES, N_SAMPLES, 32)) {
438437
Serial.println("Failed to start DAC1 !");
@@ -446,8 +445,8 @@ void loop() {
446445
if (cmd != '\n') {
447446
generate_waveform(cmd);
448447
}
449-
}
450-
448+
}
449+
451450
if (dac0.available()) {
452451
// Get a free buffer for writing.
453452
SampleBuffer buf = dac0.dequeue();
@@ -464,22 +463,23 @@ void loop() {
464463

465464
## Audio Playback
466465

467-
The GIGA R1 12-bit DAC channels can also be used to read `.wav` files from a USB stick and stream them directly to a speaker.
466+
The GIGA R1 12-bit DAC channels can also be used to read `.wav` files from a USB stick and stream them directly to a speaker.
468467

469468
For this example, you will need:
469+
470470
- A speaker, that has a built in amplifier.
471471
- A USB mass storage device (USB stick).\*
472472
- [Arduino_USBHostMbed5](https://github.com/arduino-libraries/Arduino_USBHostMbed5) library installed.
473473

474-
***\*USB mass storage devices connected needs to be formatted with the FAT32 as a file system, using the MBR partitioning scheme. Read more in the [USB Mass Storage](/tutorials/giga-r1-wifi/giga-usb/#usb-mass-storage) section.***
474+
**_\*USB mass storage devices connected needs to be formatted with the FAT32 as a file system, using the MBR partitioning scheme. Read more in the [USB Mass Storage](/tutorials/giga-r1-wifi/giga-usb/#usb-mass-storage) section._**
475475

476476
### USB Stick Configuration
477477

478-
The **Arduino_AdvancedAnalog** library contains the necessary functions that enable us to use the advanced capabilities of the GIGA R1 DACs.
478+
The **Arduino_AdvancedAnalog** library contains the necessary functions that enable us to use the advanced capabilities of the GIGA R1 DACs.
479479

480-
To read `.wav` files from the USB stick we are using the **Arduino_USBHostMbed5** library. It is important that the USB stick is formatted properly, and that we define its name in the sketch. In this case, we name it `USB_DRIVE`, and is defined like this:
480+
To read `.wav` files from the USB stick we are using the **Arduino_USBHostMbed5** library. It is important that the USB stick is formatted properly, and that we define its name in the sketch. In this case, we name it `USB_DRIVE`, and is defined like this:
481481

482-
```arduino
482+
```arduino
483483
mbed::FATFileSystem usb("USB_DRIVE");
484484
```
485485

@@ -663,7 +663,7 @@ This example is similar to the **Play Single Audio File** example, but with some
663663

664664
- This example uses multiple audio files.
665665
- The file read is moved to a separate function, `configFile()`, as it will be continuously called from the sketch.
666-
- Instead of playing a file once, it keeps looping it.
666+
- Instead of playing a file once, it keeps looping it.
667667
- The **BOOT0** (`PC_13`) button (right next to the audio jack) is used as a regular pushbutton to loop through the audio files.
668668
- Pressing the button changes the file played.
669669

@@ -919,4 +919,4 @@ void onPDMdata() {
919919
PDM.read(sampleBuffer, bytesAvailable);
920920
samplesRead = bytesAvailable / 2;
921921
}
922-
```
922+
```

0 commit comments

Comments
 (0)