Saturday, April 30, 2022

Conquering the very first challenge for the Sparkfun Edge board

A couple of months back, I became interested to learn TinyML to build machine learning "edge" applications on microcontrollers. I got hold of the book "TinyML" by Peter Warden [ISBN: 9352139607] and started scanning through it. Among the three boards mentioned by Peter, I was attracted to "Sparkfun Edge" as the author stated the collaboration he had with Ambiq, the manufacturer of the Apollo 3 microcontroller and Sparkfun, the manufacturer of the board while writing this book. Also, I found the cost of this board to be reasonable - $16.5. Therefore I decided to buy it!    

Figure 1: Sparkfun Edge with USB to 3.3V TTL (CH340G) breakout

In case you are also using this board for the first time, here is a gist about the features of Sparkfun Edge: The board is based on the Apollo 3 MCU, which is built around an ARM Cortex-M4 core, that can run at 48 MHz and up to even 96 MHz in TurboSPOT mode. This tiny 5 x 5 mm package comes with a load of features including an FPU, integrated BLE5. The functional block diagram of Ambiq's Apollo 3 MCU shows its features:

Figure: Block diagram of Apollo 3 MCU from Ambiq - Source: Datasheet 

Apart from the fairly powerful MCU, the board has 2 MEMs microphones, one 3-axis accelerometer, one camera connector for the HIMAX HM01B0 camera, four LEDs, GPIOs, and a coin cell (CR2032) connector. The BLE5 antenna is assembled on the board and it does not require an external antenna.

Well, all looked great, till I received the board I ordered. All the other boards I used so far came with either a USB connector or a pin-jack type of connector for applying power to the board. I realised that Sparkfun Edge was missing such an easy feature, which provides convenience to the users. Do not know why it was not done, but guessing, to keep the size of the board smaller? From the Sparkfun website, I found out that, I need to have a USB to TTL (3.3V) breakout board in order to program the MCU on the Edge board. Sparkfun recommends the USB-C to TTL (3.3V) breakout board ($9.95), based on the CH340C chip.

Figure 3: Sparkfun Serial Breakout Board - USB-C to TTL (CH340C)

[Picture Source: www.sparkfun.com]

I could find a $2 option for the USB to TTL breakout (branded as "WEMOS"), which has 5V as the default logic/power option for the TTL but can be configured by a jumper connection. The TTL connector has the exact pinout as the Sparkfun serial breakout board. There is one more jumper, which is needed to be configured to configure "CTS" as the data flow control signal. Ensure that you check the continuity with a multimeter after desoldering the default jumper pads and soldering the correct connections. I had to cut the default connection track (for 5V & RTS), before soldering the pads to select 3.3V and CTS.

Before connecting the serial breakout board to the Sparkfun Edge, you might want to double-check if you are getting 3.3V between the VCC and GND pin on the TTL connector while powering the serial breakout board alone. Once you are confirmed that the serial breakout board is correctly configured, connect it to the Sparkfun Edge board. As the Sparkfun Edge board comes preprogrammed with the speech recognition program, you might see the blue LED (GPIO# 37) blinking fast. That means, your Sparkfun Edge is powered up successfully.

Now here comes the challenge. The instructions for using Arduino IDE to program the SparkFun Edge board can be found on Sparkfun's webpage:

Programming the SparkFun Edge with Arduino - learn.sparkfun.com

But the instruction provided in the "The Upload Sequence" section is not entirely accurate. A small error in one step has cost me a week's effort. The instructions as written:

  • Press and hold the Reset button
  • While still holding down the Reset button, press and hold the 14 button
  • Release the Reset Button
  • Release the 14 button (Wrong!!!)
  • Hit Upload in the Arduino IDE (or use your keyboard shortcut)

The 4th step is not correct. If button# 14 is released before the upload is completed, the programming fails! It will only work if button# 14 is kept pressed and not released unless the upload is completed. In case you are struggling with the same matter, pay attention that button# 14 is kept pressed after 2nd step till the programming is completed. I got this clue after I posted this question in the forum:

Failing to upload to Sparkfun Edge board using Arduino IDE 1.8.19 · Issue #461 · sparkfun/Arduino_Apollo3 (github.com)

 

Thursday, April 7, 2022

Test your knowledge in Arduino and ATmega328P: QUIZ# 2

 


[Picture Source: https://content.arduino.cc/assets/Pinout-UNOrev3_latest.png]

Arduino Quiz# 2

1. As the pins A0 to A5 are configured as Analog Input pins on Arduino UNO, it is not necessary to declare the pins as input pins using the function pinMode(). State true or false.

A. True
B. False

2. Which one of the following statements is not correct about the microcontroller ATmega328P?

A. The IO port registers PORTx and DDRx are read/write types, whereas the PINx register is a read-only type
B. The six of the PORTC pins are configured as Analog Input on Arduino UNO
C. All ports B, C and D could be configured as digital input/output along with other functions
D. The ADC inside ATmega328P is six channel 10-bit ADC
E. None of the above

3. The IO ports of ATmega328P are controlled and accessed by three registers:

A. DDRx, PORTx and LOADx
B. DDRx, PINx and LOADx
C. PORTx, PINx and DDRx
D. PINx, PUSHx and POPx
E. None of the above

4. The IO port registers are basically built out of:

A. Diodes
B. D-FFs
C. RS FFs
D. Wire junctions
E. None of the above

5. Stack Pointer register increments by 1 during the execution of a POP instruction execution and decrements by 1 during PUSH instruction execution.

A. True
B. False

6. If the ADC of ATmega328P on Arduino UNO is configured to use the internal voltage reference, the analog values 0 and 1023 read on pin A0 using the analogRead() function would correspond to:

A. 0V and 5V respectively
B. 0V and 1.1V respectively
C. 0.1V and 4V respectively
D. 0V and 4V respectively
E. None of the above

7. STACK has majorly two uses. Those are:

A. as temporary storage for variables, the values which are needed to be restored later and to store the Stack Pointer
B. to store the return address during function calls and as temporary storage for variables, the values which are needed to be restored later
C. to manipulate data during program execution and to store the return address during function calls
D. to store instructions and to store the addressed of the functions

8. Assume that the ADC of ATmega328P on Arduino UNO has the default configuration for reference voltage (AREF). What is the LSB in terms of voltage?

A. 4.25 mV
B. 0.12 V
C. 4.88 mV
D. 3.26 mV
E. None of the above

9. Data memory read access is faster than the same for program memory.

A. True
B. False

10. PINx register can be read or be written as well by the program. State whether true or false:

A. True
B. False

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Answers for Quiz# 1 (in the previous post):

1. B     2. A     3. C     4. A.    5. A    6. A    7. A    8. A    9. C    10. D

 


Tuesday, April 5, 2022

Test your knowledge in Arduino and ATmega328P

 


Arduino QUIZ# 1

1. As the AVR CPU has a 16-bit wide address bus, the ATmega328P microcontroller is known to be a 16-bit microcontroller.

A. True

B. False

2. The Program Counter register of the microcontroller ATmega328P [select the correct answer from the choices below]

A. is a 14-bit register which contains the address of the instruction stored in the program memory

B. is a 8-bit register which contains the address of the instruction stored in the data memory

C. is a 16-bit register which is part of the 32 general-purpose registers

D. is a 14-bit register, which contains the result of the ALU operation

3. The second phase in an AVR CPU cycle is called "Execution" and this phase is subdivided into [select the correct answer from the choices below]

A. ROF, ALU

B. ROF, IF, ALU

C. ALU, ROF and RWB

D. IF, ROF and RWB

4. Pipelining helps in implementing a certain amount of parallelism in the CPU execution and IF phases so that the RISC CPU could finish most of its instructions in a single clock cycle. [True/False]

A. True

B. False

5. The execution phase might involve ALU operation and read/write operation from/into general-purpose registers and/or data memory. [True/False] 

A. True

B. False

6. Boot Loader is a program that helps the application program image to get uploaded in the desired sections of the program memory. [True/False]

A. True

B. False 

7. As the Program Counter (PC) of ATmega328P is a 14-bit register, it allows access of 32KB of program memory organized in 16K x 16 bits. [True/False]

A. True

B. False 

8. An occurrence of an interrupt for the ATmega328P microcontroller is independent of ALU operation. [True/False]

A. True

B. False  

9. How many Pin Change Interrupt inputs are available on Arduino UNO?

A. 3

B. 10

C. 23

D. 16 

10. Which of the following statements is NOT correct about the polling method?

A. In polling method, the microcontroller keeps on checking an input repeatedly in a loop to determine its state of change

B. Polling method is not efficient to determine the state of change of an external digital input

C. On Arduino UNO, the analog inputs can be checked by polling method

D. In polling method of reading any change of a digital input, there is no chance of missing a transition 

Can you guess the answers correct? Answers to follow in the next post. 😉