TAILIEUCHUNG - PROGRAMMING AND CUSTOMIZING THE PIC MICROCONTROLLER 3rd phần 4

Mặc dù có một số công ty đã tạo ra các IDE và các công cụ phát triển cho vi điều khiển PIC, tôi tin rằng Microchip MPLAB IDE là tốt nhất, cho cả người mới bắt đầu cũng như phát triển kinh nghiệm. MPLAB IDE cung cấp chức năng phát triển cơ bản, bao gồm một biên tập viên, | Simpo PDF Merge and Split Unregistered Version - http i ArrayVar 3 Simulate an array read movlw 2 Calculate Offset to 3rd Element addwf FSR f movf INDF w Get the 3rd Element movwf i and store it movlw -2 Restore FSR to point to first element addwf FSR f This code has to first add 2 to the current address in the FSR followed by loading and storing the third element and then returning the index pointer to the first element in the array. Now compare this to the same code for the PIC18 in which FSR0 which means that the PLUSW0 register will be used to access the data points to the start of ArrayVar. i ArrayVar 3 Simulate an array read movlw 2 Want Offset to the 3rd Element movff PLUSW0 i Move Contents of ArrayVar 3 into i The PREINC and POSTDEC INDF registers can be used for popping and pushing respectively data onto a stack pointed to by an FSR register. The POSTDEC INDF register is used for the push operation because it will allow the access of pushed data using the PLUSW INDF register as shown in the previous example. Using FSR0 for the stack the byte push function could be as simple as BytePush Push the contents of i onto the stack movff i POSTDEC0 return and the byte pop could be BytePop Pop the top of the stack movff PREINC0 i return The PLUSW INDF register comes in useful for high level functions in which data has been pushed onto the stack to implement temporary variables. In the example below I have specified a function that uses a data stack and with the parameters and local variables the same thing being pushed onto a stack implemented with FSR0 int StackDemo char i char j i is stack top j is one less char k 0 k is at two less than stack top movlw 0 Initialize k to zero movwf POSTDEC 0 i j k Perform a basic calculation movlw 2 Get offset to j Simpo PDFGrerge andjSplit Unregistered Version - http movff Temp PLUSW0 movlw 1 movf PLUSW0 addwf Temp f 0 movlw 3 movff PLUSW0 Temp Store value in Temp Get offset to k Add k to j in

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.