5
14/07/2013 [dsPIC33F]Làm quen MpLAB IDE (P3) | (% vutuda.wordpress.com/2012/02/24/dspiclam-quen-mplab-ide-p3/ 1/5 (% [dsPIC33F]Làm quen MpLAB IDE (P3) Posted by vtd on February 24, 2012 Debug dùng MpLAB Sim Simulator - Để đặt tốc độ clock bộ xử lý cho Simulator, chọn Debugger -> Settings, chỉnh 20 MHz. (http://vutuda.files.wordpress.com/2012/02/settings2.jpg) .:. Tốc độ chạy của Simulator phụ thuộc vào PC, do đó nó ko chạy tốc độ thực của dsPIC30F DSC đã thiết lập ở trên. Tuy nhiên, mọi tính toán thời gian đều dựa theo giá trị clock này. .:. Một cách để đo thời gian trong Simulator là dùng Stopwatch. Chọn Debugger -> Stopwatch. (http://vutuda.files.wordpress.com/2012/02/stopwatch.jpg)

[dsPIC33F]Làm quen MpLAB IDE (P3) _ (%.pdf

Embed Size (px)

Citation preview

Page 1: [dsPIC33F]Làm quen MpLAB IDE (P3) _ (%.pdf

14/07/2013 [dsPIC33F]Làm quen MpLAB IDE (P3) | (%

vutuda.wordpress.com/2012/02/24/dspiclam-quen-mplab-ide-p3/ 1/5

(%

[dsPIC33F]Làm quen MpLAB IDE (P3)

Posted by vtd on February 24, 2012Debug dùng MpLAB Sim Simulator

- Để đặt tốc độ clock bộ xử lý cho Simulator, chọn Debugger -> Settings, chỉnh 20 MHz.

(http://vutuda.files.wordpress.com/2012/02/settings2.jpg)

.:. Tốc độ chạy của Simulator phụ thuộc vào PC, do đó nó ko chạy tốc độ thực của dsPIC30F DSC đãthiết lập ở trên. Tuy nhiên, mọi tính toán thời gian đều dựa theo giá trị clock này.

.:. Một cách để đo thời gian trong Simulator là dùng Stopwatch. Chọn Debugger -> Stopwatch.

(http://vutuda.files.wordpress.com/2012/02/stopwatch.jpg)

Page 2: [dsPIC33F]Làm quen MpLAB IDE (P3) _ (%.pdf

14/07/2013 [dsPIC33F]Làm quen MpLAB IDE (P3) | (%

vutuda.wordpress.com/2012/02/24/dspiclam-quen-mplab-ide-p3/ 2/5

.:. Stopwatch luôn được xóa khi Reset Simulator.

- Đặt breakpoint tại “main_counter++”, ấn Run để chạy mô phỏng.

(http://vutuda.files.wordpress.com/2012/02/test.jpg)

.:. Ở đây, việc thiết lập các thông số mất 21.6 us.

.:. Nếu ấn “Zero” -> cột bên phải là tổng thời gian, cột bên trái là thời gian cần để thực hiện 1 vòng lặpđể trở về đúng breakpoint hiện tại.

- Thiết lập để xem sự thay đổi giá trị các biến.

(http://vutuda.files.wordpress.com/2012/02/watch.jpg)

.:. Biến local không hiện địa chỉ.

.:. Để hiển thị giá trị thập phân thay vì hexa -> right-click vào biến cần hiển thị trong cửa sổ Watch ->chọn Properties.

Page 3: [dsPIC33F]Làm quen MpLAB IDE (P3) _ (%.pdf

14/07/2013 [dsPIC33F]Làm quen MpLAB IDE (P3) | (%

vutuda.wordpress.com/2012/02/24/dspiclam-quen-mplab-ide-p3/ 3/5

(http://vutuda.files.wordpress.com/2012/02/dec.jpg)

- Giờ remove breakpoint cũ, đặt breakpoint mới tại “irq_counter++” trong ISR để kiểm trả các thôngsố & thời gian xảy ra ngắt timer. Chọn Run để chạy mô phỏng.

(http://vutuda.files.wordpress.com/2012/02/check.jpg)

.:. Có ngắt sau ~ 1 ms.

- Nếu đặt breakpoint tại “sticks = 0″, sau đó Run, khi đó sticks đã tăng đến 1000 & điều kiện (sticks ==

1000) thỏa mãn -> đã có 1000 lần ngắt xảy ra -> Thời gian đã trôi qua 1000*1 ms = 1 s.

Page 4: [dsPIC33F]Làm quen MpLAB IDE (P3) _ (%.pdf

14/07/2013 [dsPIC33F]Làm quen MpLAB IDE (P3) | (%

vutuda.wordpress.com/2012/02/24/dspiclam-quen-mplab-ide-p3/ 4/5

(http://vutuda.files.wordpress.com/2012/02/check2.jpg)

.:. Khi cài MpLAB X v1.5 trên win7 x64 có thể gặp trường hợp “Cannot find include file” nhưng vẫnbuild bình thường (tuy nhiên không có hint khi truy xuất các thanh ghi). Cách khắc phục như sau:

Page 5: [dsPIC33F]Làm quen MpLAB IDE (P3) _ (%.pdf

14/07/2013 [dsPIC33F]Làm quen MpLAB IDE (P3) | (%

vutuda.wordpress.com/2012/02/24/dspiclam-quen-mplab-ide-p3/ 5/5

(http://vutuda.files.wordpress.com/2012/02/mplabx.jpg)

This entry was posted in MpLAB IDE. Bookmark the permalink.

Blog at WordPress.com. | The Piano Black Theme.

About these ads (http://en.wordpress.com/about-these-ads/)