之前筆者我也常常有一個困擾,STM32的SPEC很多,而且還很多頁,真的不知道該從何下手。很多人這就是這樣,在沒有人帶領之下,又花了很多時間,慢慢的就放棄學習STM32了;你害怕了嗎?沒關係,筆者會用比較簡單的介紹,來介紹ST在網頁上,SPEC的分類,和如何快速有效的找出你想要的資料,也避免因為不熟悉,而浪費過多的時間在上面。
2013年1月30日 星期三
[STM32F3 教學] 如何看spec和找資料
之前筆者我也常常有一個困擾,STM32的SPEC很多,而且還很多頁,真的不知道該從何下手。很多人這就是這樣,在沒有人帶領之下,又花了很多時間,慢慢的就放棄學習STM32了;你害怕了嗎?沒關係,筆者會用比較簡單的介紹,來介紹ST在網頁上,SPEC的分類,和如何快速有效的找出你想要的資料,也避免因為不熟悉,而浪費過多的時間在上面。
2013年1月5日 星期六
[STM32F3 教學] (MDK)Keil debug 方法
今天來介紹一下,如何使用STM32F3 Discovery。
如果有需要的人,可以找我購買,這是我最近在弄的副業,希望大大多多幫忙:
http://goods.ruten.com.tw/item/show?21212019308469
因為這塊板子有內建ICE: ST-LINK/V2 其實是非常划算的一塊板子:
ICE相關的頁面可以參考:http://www.st.com/internet/evalboard/product/251168.jsp
ICE Driver:http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/SW_DRIVER/st-link_v2_usbdriver.zip
以下是這塊discovery的介紹:
此MCU為ARM base cortex-M4,256KB flash,48KB RAM,最高可以跑在72MHZ包含了DSP,他最強的功能在他的類比電路
包含了:高速12bit ADC(四通道,最多39組,最高5Msps取樣),12bit DAC, 其中還有7組比較器和4組OPA(這只能微調,2/4/8/16倍放大,雖然可調性不多,但在MCU來說,已經非常強悍了)。
三軸陀螺儀(Gyro),L3GD20: http://www.st.com/internet/analog/product/252443.jsp
三軸加速規(accelerometor)+三軸電子羅盤(compass),LSM303DLHC: http://www.st.com/internet/analog/product/251940.jsp
這次的內容是要介紹如何使用MDK(Keil)配合ICE:
1、 Option
2、debug確認有選好ICE - ST-LINK/V2。
3、utility確認選好ICE- ST-LINK/V2。
4、進入Debug mode。
進入debug mode時, 選擇我們要設定的暫存器。
我們可以看一下LED的介紹, 這塊板子的LED 都使用 PE.x的腳位。
4.4 LEDs
● LD1 PWR: red LED indicates that the board is powered.
● LD2 COM: LD2 default status is red. LD2 turns to green to indicate that
communications are in progress between the PC and the ST-LINK/V2.
● User LD3: red LED is a user LED connected to the I/O PE9 of the STM32F303VCT6.
● User LD4: blue LED is a user LED connected to the I/O PE8 of the STM32F303VCT6.
● User LD5: orange LED is a user LED connected to the I/O PE10 of the
STM32F303VCT6.
● User LD6: green LED is a user LED connected to the I/O PE15 of the
STM32F303VCT6.
● User LD7: green LED is a user LED connected to the I/O PE11 of the
STM32F303VCT6.
● User LD8: orange LED is a user LED connected to the I/O PE14 of the
STM32F303VCT6.
● User LD9: blue LED is a user LED connected to the I/O PE12 of the STM32F303VCT6.
● User LD10: red LED is a user LED connected to the I/O PE13 of the STM32F303VCT6.
1、先設好斷點如2的位置。
2、按run
3、可以測試一下gpio的狀況,點點看,可以看到LED燈的變化。
這實在是ICE 非常好用的功能
另外就是我們常需要使用的部分,如果我們要觀察變數的地方。可以照下面的方法操作。
以上是簡單介紹如何用Keil 使用ICE 做debug的方式。
希望對大家有幫助。
2012年12月7日 星期五
TI sample
之前看了naga大大的blog,就跟著他申請sample。
可惜,他的那幾個我還滿想申請的,但我申請的時後,已經被申請完了,太可惜了
不過我也申請了一個馬達driver。
話說TI還真是大方,這些都是免費,超贊的啦!
不過因為都只有IC,我又要頭痛了。
對了,還有附上DATASHEETㄟ,超酷的。
STM32F3 dicovery 實驗板
最近買了一個不錯玩的玩具stm32f3, 這塊開發板包含ICE/3軸陀螺儀/3軸加速規/3軸電子指北針
超便宜的。 才幾百元,有興趣的人可以在這裡購買。
後來發現這顆MCU也是新的,所以要灌新的KEIL才有辦法compiler。 目前我就灌4.6就可以執行了。
有興趣的可以自己下載資料來看:
原廠support: http://www.st.com/internet/evalboard/product/254044.jsp
ST-LINK driver: http://www.st.com/internet/evalboard/product/251168.jsp
2012年8月15日 星期三
OBJ 陣列 for VC++
之前寫VC++ 都會用很笨的方式在寫, 最近發現,原來是可以用成陣列的方式在寫,
這樣的程式就可以省很多空間了
假設我有3個textBox 的OBJ, 那以寫的方式會用
textBox1->Text = "123";
textBox2->Text = "123";
textBox3->Text = "123";
如果OBJ多了一點,這樣就只好用EXCEL 來幫助寫程式了。
其實,還有更好的方式,用OBJ的ARRAY來寫:
以下是個範例:
先宣告一個GLOBAL 變數
public ref class Form1 : public System::Windows::Forms::Form
{
public:
static array <System::Windows::Forms::TextBox^> ^TextBoxArray = gcnew array <System::Windows::Forms::TextBox^>(10);
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
}
接著在LOAD FORM時,載入物件
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
int i;
TextBoxArray [0] = textBox3;
TextBoxArray [1] = textBox4;
TextBoxArray [2] = textBox5;
for (i =0; i<3; i++)
{
TextBoxArray [i]->Text = "ABC";
}
}
最後做一個BUTTON來做測試其他功能
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int i;
TextBoxArray [0] = textBox3;
TextBoxArray [1] = textBox4;
TextBoxArray [2] = textBox5;
for (i =0; i<3; i++)
{
TextBoxArray [i]->Text = "kkk";
}
}
好棒,這樣程式碼就可以乾淨許多

