[TH] Arduino: STM32L432 Nucleo-32’s DAC&ADC.

จากที่ได้อ่านบทความ การใช้งาน STM32 Core Support for Arduino สำหรับบอร์ด Nucleo L432KC ของอาจารย์ เรวัต ศิริโภคาภิรมย์ ทางเราเลยได้จัดหาบอร์ดมาทดลองใช้งานและเชื่อมต่อขาสำหรับส่งข้อมูลออก DAC ไปยัง ADC ตามภาพที่ 1 เพื่อทดสอบการทำงานของภาค DAC และ ADC ของบอร์ดโดยใช้โค้ดการทำงานเหมือนกับบอร์ดไมโครคอนโทรลเลอร์ ESP32, SAM-D21 และ LGT8F328P ว่าเป็นอย่างไร มาติดตามกันครับ

ภาพที่ 1 บอร์ด Neucleo L432KC เชื่อมต่อขา A3 เข้ากับ D3
Read More

[EN] u8g2 Library

From the article on using the ESP8266 with an OLED graphical display written in Python, you’ll find that it’s fast and easy but when used with other microcontrollers that cannot use Micropython or CircuitPython, what must be done? One of the many options is the u8glib or u8g2 (Universal 8 bit Graphics Library) libraries, designed to work with monochromatic 8-bit graphics over either I2C or SPI communication. In this article, we are using I2C OLED as shown in Figure 1.

(Figure. 1 STM32F401CCU6 with I2C OLED)
Read More

[EN] SPI Bus

This article discusses the SPI bus functionality of the Arduino framework for use with the STM32F030F4P6, STM32F103C8, STM32F401, esp8266 and esp32. The operation of this bus requires at least 3 intercommunication cables: SCLK, MISO. and MOSI for transmitting the clock signal between the sender and the receiver. It serves to receive information from the sender. and used for sending information to the recipient.

From the use of 3 signal lines, it is found that data can be transmitted and received simultaneously. This is different from I2C bus communication that uses only one SDA cable to communicate. At the same communication speed, the SPI bus will receive and transmit data without waiting for an idle line, while I2C will have to wait for idle. With this in mind, SPI can send/receive data faster.

In addition, SPI uses a method to select the destination to communicate by instructing the endpoint to know by sending a signal to the SS pin of the terminal. Therefore, when connecting to multiple devices, SPI requires a larger number of pins to operate, while I2C uses device identification to communicate with each other by still using only one SDA cable, which saves more pins.

Read More

[TH] Draw an analog clock using MicroPython.

บทความก่อนหน้านี้ได้กล่าวถึงการปรับปรุงปรับปรุงความเร็วในการแสดงผลด้วยการใช้เทคนิคดับเบิลบัฟเฟอร์ (double buffer) จึงนำมาประยุกต์ใช้สำหรับการแสดงผลเป็นนาฬิกาแบบแอนาล็อกดังภาพที่ 1 ซึ่งวิธีการวาดนั้นใช้การคำนวณตรีโกณมิติเพื่อหาค่าพิกัด (x,y) ของปลายเข็มวินาที นาที และชั่วโมง โดยการทำงานของแต่ละวินาทีจะใช้ตัวตั้งเวลาหรือไทเมอร์ (Timer) เพื่อให้การทำงานนั้นใกล้เคียงกับเวลาจริงมากกว่าการวนรอบหรือการหน่วงเวลา

ภาพที่ 1 ตัวอย่างผลลัพธ์ของการวาดนาฬิกาแบบแอนาล็อก
Read More

[TH] MicroPython : pyb USB_HID/USB_VCP

บทความนี้กล่าวถึงการใช้ความสามารถเกี่ยวกับ USB HID ของบอร์ดไมโครคอนโทรลเลอร์ STM32F411CEU6 ผ่านทาง MicroPython ในคลาส pyb ซึ่งทีมงานเราได้แรงบันดาลใจจากบทความ MicroPython for STM32F411 Black Pill: Embedded Programming Style ของอาจารย์ดร.เรวัต ศิริโภคาภิรมย์ ว่าแล้วมาเริ่มคอมไพล์และอัพโหลดเฟิร์มแวร์กันได้เลยครับ (อ่านรายละเอียดได้จากบทความของอาจารย์ดร.เรวัต ศิริโภคาภิรมย์ ได้เลยครับ) โดยเราใช้บอร์ดเลียนแบบ WeAct STM32F411CEU6 ดังภาพที่ 1 ซึ่งเมื่อติดตั้ง MicroPython จะมีคลาส pyb ให้ใช้งาน

ภาพที่ 1 บอร์ดสำหรับการทดลองในบทความนี้
Read More

[EN] Bare Metal Cortex-M Ep.3

From the previous article, we have experimented with controlling the digital signal output by driving the LED circuit connected to the STM32 microcontroller board, both Cortex-M0, Cortex-M3 and Cortex-M4. to import digital signals and use an example of connecting a switch circuit to control the on or off of an LED lamp as shown in Figure 1.

(Figure. 1 Our board in this article)
Read More

[EN] Bare Metal Cortex-M Ep.2

From the previous article, we have tried writing a program to study the elements of various files that we need, we found that there are quite a lot of details and steps. But it is an important basis for those who want to seriously and usefully study Cortex-M0 programming via STM32F030F4P6 (Figure 1), Cortex-M3 with STM32F103C (Figure 32) and Cortex-M4 with STM32F401CCU6 (Figure 27) to study of programming structure with programming tool STM32CubeIDE (Figure 2), which is the main tool used in this series of articles. This is because it combines ST’s complete development kit for ARM, including CubeMX for chip design, compiler toolkit, ST-Link program debugging tool and code editor in one tool,  plus it supports both Windows, Linux and macOS operating systems.

(Figure. 1 STM32F030F4P6 and USB–RS232 )
Read More

[EN] Bare Metal Cortex-M Ep.1

This article is a series of programming articles focused on the Cortex-M0 via the STM32F030F4P6 or any other STM32 microcontroller based on CMSIS, an ARM firmware compiled from vivonomicon.com‘s series of Bare Metal: STM32 Programming articles without using the Arduino framework. In the article EP.1 is a matter of preparation. It consists of creating a link file to link different parts of the code together and the working part file. After that, the result file is uploaded into the microcontroller to complete the program development process.

(Figure. 1 STM32F030F4P6)
Read More

[TH] How to used Arduino 2.4″ TFT LCD&Touch Shield with STM32F401?

จากบทความก่อนหน้านี้ที่ได้ใช้จอแสดงผลขนาด 3.5″ สำหรับบอร์ด Raspberry Pi มาใช้งานกับ ESP32 ไปแล้ว ทางทีมงานเรายังมี Arduino 2.4″ TFT LCD&Touch Shield ที่ใช้กับ Arduino Uno และ Arduino Mega (ดังภาพที่ 1) และต้องการใช้งานกับไมโครคอนโทรลเลอร์ STM32F401RET6 ด้วยบอร์ด NUCLEO-F401RE และ STM32F401CC (ภาพที่ 2) ซึ่งเป็น Cortex-M4 ที่มีหน่วยความจำ 96KB และ 64KB ตามลำดับ ส่วนหน่วยความจำ ROM นั้นเป็น 512KB และ 128KB พร้อมทั้งทำการเชื่อมต่อสวิตช์จำนวน 8 ตัวเข้ากับขาของไมโครคอนโทรลเลอร์ โดยในบทความนี้ใช้บอร์ด ET-TEST 10P/INP (ภาพที่ 3) เพื่อใช้แทนปุ่มซ้าย, บน, ล่าง,ขวา, m1,m2, A และ B ตามลำดับ

Nucleo-F401RE+Arduino Uno 2.4" TFT&Touch Shield
ภาพที่ 1 โมดูล Arduino Uno TFT&Touch Shield บนบอร์ด Nucleo-F401RE
Read More

[TH] Bare Metal Cortex-M Ep.4

บทความนี้กล่าวถึงการใช้งานพอร์ตสื่อสารอนุกรม UART ซึ่งนิยมใช้มานาน และสะดวกต่อการใช้งาน โดยใช้ขา PA9 และ PA10 ต่อเข้าเป็นขา Tx และ Rx ของไมโครคอนโทรลเลอร์ทั้ง cortex-M0/M3/M4 เชื่อมต่อกับขา Rx/Tx ของตัวแปลงระดับแรงดันสัญญาณสำหรับสื่อสารผ่านทางพอร์ต USB ซึ่งตัวอย่างโปรแกรมเป็นการประมวลผลในไมโครคอนโทรลเลอร์และนำออกผลลัพธ์ผ่านทางพอร์ตสื่อสารอนุกรมที่ใช้งานโปรแกรม moserial เป็นซอฟต์แวร์สื่อสารข้อมูลดังภาพที่ 1

ภาพที่ 1 ตัวอย่างผลลัพธ์จากการทำงานของโปรแกรมตัวอย่าง
Read More