MCU: различия между версиями
Sergey (обсуждение | вклад) (→STM8) |
Sergey (обсуждение | вклад) (→STM8) |
||
Строка 12: | Строка 12: | ||
compilers comparation http://www.colecovision.eu/stm8/compilers.shtml | compilers comparation http://www.colecovision.eu/stm8/compilers.shtml | ||
+ | |||
+ | samples https://www.hodges.org/rh/stm8/ | ||
=== startup === | === startup === |
Текущая версия на 16:10, 21 февраля 2023
cam
ESP32-CAM OV2460
links
Lightweight C compilers http://fun4diy.com/
STM8
compilers comparation http://www.colecovision.eu/stm8/compilers.shtml
samples https://www.hodges.org/rh/stm8/
startup
- Power requirements: 3.3-5V
- Reset circuit (100nF cap)
- Select clock source (ext.crystal/HSI)
- Choose halt modes for
- flash
- HSI, HSE
- use timer or AWU for wake-up if no ext.ints
- calibrate LSI osc.
- configure GPIO
- use watchdog
AWU
- on int disable AWU (or new int will be generated instantly)
- before re-enable re-load counter
UART
- word length: UART_CR1.M - stop bits: UART_CR3 - baud rate: UART_BRR2 then UART_BRR1 - en transmitter: UART_CR2.TEN - send data: UART_DR and wait until TC goes 1
UART_DR:
write goes to TDR read goes from RDR
TXE: set at end of transmission (and if TIEN then int is generated) - can send more
wait for TXE before write DR
TC: transmission complete (and if TCIEN then int is generated) - may disable transmitter
SBK bit: send break character (do not set again before prv break is sent)
UART_CR1.R8: MSB for received 9-bit words
NF: set when start bit has spurious '1's
- en receiver: UART_CR2.REN
clear REN to abort receive immediately
RXNE: set when data moved to RDR (and intr if RIEN set)
if char is received without RXNE reset then overrun error raised
break char: received as framing error
idle char: intr if ILIEN set
- UART_CR1.PCEN : one bit of total length will be used for parity - UART_CR1.PS : even/odd parity
- UART_CR1.RWU: mute mode. WAKE = 0: until idle, WAKE = 1: listen for address (MSB=1 as mark of address - 4 bits LSB) - UART_CR4.ADD: own address - only first byte after idle considered as possibly containing address mark? not clear.
jobs
MAYHALT - semaphore, must be incremented on start of each no-halt process e.g. UART TX syssleep func:
check for mayhalt if zero halt if not wfi loop if no jobs else get toppest by pri and start
sysjobs:
populated with int handlers, address of jobs to run (with associated data ptr)
sysqueues:
if smth is put on it, associated job is created by system queue record: what to do, data, completion action
for example, if program puts report on send queue and queue is full, program must be suspended or something in queue must be deleted
alternatively, program can put something on queue, asking to suspend self and to be resumed on completion
applications
* receive byte from serial and set ON/OFF switches * receive byte from serial and set voltage * one MCU reads ON/OFF or voltage and send to another to set same ON/OFF or voltage value