Học PIC từ cơ bản-2

PIC là họ vi điều khiển mạnh, giàu tài nguyên về phần cứng, được microchip hỗ trợ nhiều tài liệu. Với triết lý sống “Chia sẻ để thành công”, tại đây chúng tôi sẽ định hướng cho bạn cách tiếp cận với vi điều khiển PIC một cách nhanh nhất nhưng hiểu được cốt lõi của vấn đề sâu sắc nhất. | Gooligum Electronics 2008 Introduction to PIC Programming Programming Baseline PICs in C by DavidMeiklejohn Gooligum Electronics Lesson 2 Using Timer 0 As demonstrated in the previous lesson C can be a viable choice for programming digital I O operations on baseline 12-bit PICs although as we saw programs written in C can consume significantly more memory a limited resource on these tiny MCUs than equivalent programs written in assembler. This lesson revisits the material from baseline lesson 5 which you should refer to while working through this tutorial on the Timer0 module using it to time events to maintain the timing of a background task for switch debouncing and as a counter. Selected examples are re-implemented using the free C compilers bundled with Microchip s MPLAB HITECH C1 in Lite mode PICC-Lite and CCS PCB introduced in lesson 1 and as was done in that lesson the memory usage and code length is compared with that of assembler. We ll also see the C equivalents of some of the assembler features covered in baseline lesson 6 including macros. In summary this lesson covers Configuring Timer0 as a timer or counter Accessing Timer0 Using Timer0 for switch debouncing Using C macros with examples for HI-TECH C PICC-Lite and CCS PCB. Note that this tutorial series assumes a working knowledge of the C language it does not attempt to teach C. Example 1 Using Timer0 as an Event Timer To demonstrate how Timer0 can be used to measure elapsed time baseline lesson 5 included an example reaction timer game based on the circuit on the right where the pushbutton has to be pressed as quickly as possible after the LED on GP2 indicating start is lit. If the button is pressed quickly enough that is within some predefined reaction time the LED on GP1 is lit to indicate success . Thus we need to measure the elapsed time between indicating start and detecting a pushbutton press and an ideal way to do that is to use Timer0 in its timer 10k 1 PICC-Lite was .

Bấm vào đây để xem trước nội dung
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.