Skip to content

Commit 623dbbd

Browse files
committed
Update content.md
1 parent db692db commit 623dbbd

File tree

1 file changed

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

1 file changed

+27
-29
lines changed

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

Lines changed: 27 additions & 29 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,16 +11,15 @@ 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-
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).
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).
2019
- Generate specific waveforms through input via serial commands (triangle, square, sine, sawtooth waves) as well as adjusting the frequency.
2120
- Read and play audio files (`.wav`) from a USB stick (connected to USB-A) to a speaker, using the audio jack.
2221

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._**
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.***
2423

2524
## Hardware & Software Needed
2625

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

171170
- 8-bit or 12-bit monotonic output
172171
- Left or right data alignment in 12-bit mode
173-
- Dual DAC channel independent or simultaneous conversions
172+
- Dual DAC channel independent or simultaneous conversions
174173
- DMA capability for each channel
175174
- External triggers for conversion
176175
- Input voltage reference or internal voltage reference
@@ -261,15 +260,15 @@ void setup() {
261260
262261
void dac_output_sq(AdvancedDAC &dac_out) {
263262
if (dac_out.available()) {
264-
263+
265264
// Get a free buffer for writing.
266265
SampleBuffer buf = dac_out.dequeue();
267-
266+
268267
// Write data to buffer.
269268
for (int i=0; i<buf.size(); i++) {
270269
buf.data()[i] = (i % 2 == 0) ? 0: 0xfff;
271270
}
272-
271+
273272
// Write the buffer to DAC.
274273
dac_out.write(buf);
275274
}
@@ -349,8 +348,8 @@ AdvancedDAC dac0(A12);
349348
uint8_t SAMPLES_BUFFER[N_SAMPLES];
350349
size_t dac_frequency = DEFAULT_FREQUENCY;
351350
352-
void generate_waveform(int cmd)
353-
{
351+
void generate_waveform(int cmd)
352+
{
354353
switch (cmd) {
355354
case 't':
356355
// Triangle wave
@@ -387,29 +386,29 @@ void generate_waveform(int cmd)
387386
case '+':
388387
case '-':
389388
Serial.print("Current frequency: ");
390-
389+
391390
if (cmd == '+' && dac_frequency < 64000) {
392391
dac_frequency *= 2;
393392
} else if (cmd == '-' && dac_frequency > 1000) {
394393
dac_frequency /= 2;
395394
} else {
396395
break;
397396
}
398-
397+
399398
dac0.stop();
400399
delay(500);
401400
if (!dac0.begin(AN_RESOLUTION_8, dac_frequency * N_SAMPLES, N_SAMPLES, 32)) {
402401
Serial.println("Failed to start DAC1 !");
403402
}
404403
delay(500);
405404
break;
406-
405+
407406
default:
408407
Serial.print("Unknown command ");
409408
Serial.println((char) cmd);
410409
return;
411410
}
412-
411+
413412
Serial.print(dac_frequency/1000);
414413
Serial.println("KHz");
415414
}
@@ -421,17 +420,17 @@ void setup() {
421420
422421
}
423422
424-
423+
425424
Serial.println("Enter a command:");
426425
Serial.println("t: Triangle wave");
427426
Serial.println("q: Square wave");
428427
Serial.println("s: Sine wave");
429428
Serial.println("r: Sawtooth wave");
430429
Serial.println("+: Increase frequency");
431430
Serial.println("-: Decrease frequency");
432-
431+
433432
generate_waveform('s');
434-
433+
435434
// DAC initialization
436435
if (!dac0.begin(AN_RESOLUTION_8, DEFAULT_FREQUENCY * N_SAMPLES, N_SAMPLES, 32)) {
437436
Serial.println("Failed to start DAC1 !");
@@ -445,8 +444,8 @@ void loop() {
445444
if (cmd != '\n') {
446445
generate_waveform(cmd);
447446
}
448-
}
449-
447+
}
448+
450449
if (dac0.available()) {
451450
// Get a free buffer for writing.
452451
SampleBuffer buf = dac0.dequeue();
@@ -463,23 +462,22 @@ void loop() {
463462

464463
## Audio Playback
465464

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.
465+
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.
467466

468467
For this example, you will need:
469-
470468
- A speaker, that has a built in amplifier.
471469
- A USB mass storage device (USB stick).\*
472470
- [Arduino_USBHostMbed5](https://github.com/arduino-libraries/Arduino_USBHostMbed5) library installed.
473471

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._**
472+
***\*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.***
475473

476474
### USB Stick Configuration
477475

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

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:
478+
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:
481479

482-
```arduino
480+
```arduino
483481
mbed::FATFileSystem usb("USB_DRIVE");
484482
```
485483

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

664662
- This example uses multiple audio files.
665663
- 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.
664+
- Instead of playing a file once, it keeps looping it.
667665
- The **BOOT0** (`PC_13`) button (right next to the audio jack) is used as a regular pushbutton to loop through the audio files.
668666
- Pressing the button changes the file played.
669667

@@ -919,4 +917,4 @@ void onPDMdata() {
919917
PDM.read(sampleBuffer, bytesAvailable);
920918
samplesRead = bytesAvailable / 2;
921919
}
922-
```
920+
```

0 commit comments

Comments
 (0)