2016年6月2日 星期四

Published 下午3:16 by with 0 comment

[基礎] STM8 與開源軟體


這塊小板子叫做 STM8S105K4T6C 最小核心板,
露天拍賣售價 145 元。

然後這顆IC差不多系列的 STM8S105K4T6C
露天拍賣售價 30 元。



這兩款的差別就只是程式記憶體(Flash)大小
原廠分類圖

這顆單晶片的參數看一看,大抵上該有的介面也都有,

Key Features
  • Core
    • 16 MHz advanced STM8 core with Harvard architecture and 3-stage pipeline
    • Extended instruction set
  • Memories
    • Program memory: up to 32 Kbyte Flash; data retention 20 years at 55 °C after 10 kcycle
    • Data memory: up to 1 Kbyte true data EEPROM; endurance 300 kcycle
    • RAM: up to 2 Kbyte
  • Clock, reset and supply management
    • 2.95 to 5.5 V operating voltage
    • Flexible clock control, 4 master clock sourcesLow power crystal resonator oscillatorExternal clock inputInternal, user-trimmable 16 MHz RCInternal low-power 128 kHz RC
    • Clock security system with clock monitor
    • Power management:Low-power modes (wait, active-halt, halt)Switch-off peripheral clocks individually
    • Permanently active, low-consumption power-on and power-down reset
  • Interrupt management
    • Nested interrupt controller with 32 interrupts
    • Up to 37 external interrupts on 6 vectors
  • Timers
    • Advanced control timer: 16-bit, 4 CAPCOM channels, 3 complementary outputs, dead-time insertion and flexible synchronization
    • 2x16-bit general purpose timer, with 2+3 CAPCOM channels (IC, OC or PWM)
    • 8-bit basic timer with 8-bit prescaler
    • Auto wake-up timer
    • Window watchdog and independent watchdog timers
  • Communication interfaces
    • UART with clock output for synchronous operation, SmartCard, IrDA, LIN master mode
    • SPI interface up to 8 Mbit/s
    • I2C interface up to 400 kbit/s
  • Analog to digital converter (ADC)
    • 10-bit, ±1 LSB ADC with up to 10 multiplexed channels, scan mode and analog watchdog
  • I/Os
    • Up to 38 I/Os on a 48-pin package including 16 high sink outputs
    • Highly robust I/O design, immune against current injection
  • Unique ID
    • 96-bit unique key for each device

所以似乎蠻適合拿來當產品設計的核心使用。
同樣這種功能包一堆的MCU來說,幾乎沒有更便宜的了。

使用Open Source的Complier SDCC 和 CodeBlocks 編輯器來嘗試寫程式。

根據
http://blog.podstuff.de/setup-codeblocks-for-stm8s-discovery/
這個網制進行STM8的函式庫編成
不過他裡面寫錯了測定,新增CPU的設定應該是 -mstm8 而不是 -stm8
於是可以編出 STM8S_lib.lib 之後被其他程式引用。


再來根據
http://blog.podstuff.de/stm8s-discovery-first-program/
這樣寫個程式

於是可以得到成果
      edit

0 意見:

張貼留言