![]() |
PIC 12F629 - Đọc nút nhấn
Em viết chương trình cho con 12F629, nối đèn led với chân số 5, đầu kia của đèn led lên nguồn. Bây giờ em cho chân số 5 xuống 0 để đèn led sáng, viết chương trình không báo lỗi nhưng mô phỏng trong proteus thì không chạy. Nếu viết chương trìng cho các chân khác thì chạy bình thường, em không hiểu vì sao, nhờ các bác giúp đỡ
#include <12F629.h> #FUSES NOWDT //No Watch Dog Timer #FUSES INTRC_IO //Internal RC Osc, no CLKOUT #FUSES NOCPD //No EE protection #FUSES NOPROTECT //Code not protected from reading #FUSES MCLR //Master Clear pin enabled #FUSES NOPUT //No Power Up Timer #FUSES BROWNOUT //Reset when brownout detected #FUSES BANDGAP_HIGH #FUSES RESERVED //Used to set the reserved FUSE bits #use delay(clock=4000000) void main() { while(1) { output_low(PIN_A3); } } |
Trích:
PIN_A3 chỉ có thể làm chân input(khi sử dụng cấu hình #FUSES NOMCLR) trích data sheet: GPIO is an 6-bit wide, bi-directional port. The corre- sponding data direction register is TRISIO. Setting a TRISIO bit (= 1) will make the corresponding GPIO pin an input (i.e., put the corresponding output driver in a Hi-impedance mode). Clearing a TRISIO bit (= 0) will make the corresponding GPIO pin an output (i.e., put the contents of the output latch on the selected pin). ------------------------------------------------- The exception is GP3, which is input only and its ------------------------------------------------ TRISIO bit will always read as ‘1’. Example 3-1 shows how to initialize GPIO. |
GPIO is an 6-bit wide, bi-directional port. The corre-
sponding data direction register is TRISIO. Setting a TRISIO bit (= 1) will make the corresponding GPIO pin an input (i.e., put the corresponding output driver in a Hi-impedance mode). Clearing a TRISIO bit (= 0) will make the corresponding GPIO pin an output (i.e., put the contents of the output latch on the selected pin). ------------------------------------------------- The exception is GP3, which is input only and its ------------------------------------------------ TRISIO bit will always read as ‘1’. Example 3-1 shows how to initialize GPIO. __________________ --> chưa hiểu lắm. |
Múi giờ GMT. Hiện tại là 06:19 PM. |
Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam