1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

8 comparator assembler block

17 58 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Microcontrollers COMPARATOR MODULE Microcontrollers COMPARATOR MODULE • The comparator module contains two analog compara• tors • The inputs to the comparators are multiplexed with I/O port pins RA0 through RA3, while the outputs are multiplexed to pins RA4 and RA5 • The on-chip voltage reference can also be an input to the comparators Microcontrollers COMPARATOR I/O OPERATING MODES Microcontrollers COMPARATOR I/O OPERATING MODES Microcontrollers SINGLE COMPARATOR COMPARATOR VOLTAGE REFERENCE MODULE Microcontrollers COMPARATOR VOLTAGE REFERENCE BLOCK DIAGRAM Microcontrollers COMPARATOR VOLTAGE REFERENCE MODULE Microcontrollers COMPARATOR VOLTAGE REFERENCE MODULE #include #fuses XT,WDT,NOPROTECT #use delay(clock=4000000) #use rs232(baud=9600, xmit=PIN_D0, rcv=PIN_D1) main() { delay_ms(1000); putc(254); putc(1); delay_ms(10); printf("Voltage test"); delay_ms(1000); setup_comparator(A0_VR_A1_VR); setup_vref(VREF_HIGH|15); while(TRUE) { putc(254); putc(1); delay_ms(10); if(C1OUT){ printf("Below 3.6 V."); delay_ms(1000); } else{ printf("Above 3.6 V."); delay_ms(1000); } } } Microcontrollers PIC16 C Assembler Routines ● Reasons for using assembly language ● Insertion of assembler sequence ● Overview of assembly language Reasons for using assembly language Microcontrollers • The default programming language of any microprocessor or microcontroller is its own assembly language • Assembly language is the first-level abstraction from machine code, where each instruction is represented by a corresponding text mnemonic • When compiled, a C program is converted into assembler, then to machine code 10 Microcontrollers C Code Fragment for Pulse Output Loop #include "16F877a.h" // MCU header file void main() // Main block start { while(1) { output_high(PIN_D0); output_low(PIN_D0); } } 11 Microcontrollers Disassembled Code for Pulse Output Loop 12 Assembler Block Microcontrollers • The start of the assembler block is identified by the #asm directive and terminated with #endasm • All the code between these points must conform to the PIC assembler syntax 13 Microcontrollers Assembler Block #include "16F877A.h" #use delay(clock=4000000) #int_ext void isrext() { output_low(PIN_D0); } void main() { enable_interrupts(int_ext); delay_ms(100); while(input(PIN_B0)); enable_interrupts(global); ext_int_edge(L_TO_H); #asm Start: BSF 8,0 BCF 8,0 GOTO Start #endasm } 14 Microcontrollers Assembler Block 15 C Code Microcontrollers #include "16F877A.h" #use delay(clock=4000000) #int_ext void isrext() { output_low(PIN_D0); } void main() { enable_interrupts(int_ext); delay_ms(100); while(input(PIN_B0)); enable_interrupts(global); ext_int_edge(L_TO_H); while(1) { output_high(PIN_D0); output_low(PIN_D0); } } 16 Microcontrollers C Code 17 ... also be an input to the comparators Microcontrollers COMPARATOR I/O OPERATING MODES Microcontrollers COMPARATOR I/O OPERATING MODES Microcontrollers SINGLE COMPARATOR COMPARATOR VOLTAGE REFERENCE... Microcontrollers COMPARATOR VOLTAGE REFERENCE BLOCK DIAGRAM Microcontrollers COMPARATOR VOLTAGE REFERENCE MODULE Microcontrollers COMPARATOR VOLTAGE REFERENCE MODULE #include #fuses... enable_interrupts(global); ext_int_edge(L_TO_H); #asm Start: BSF 8, 0 BCF 8, 0 GOTO Start #endasm } 14 Microcontrollers Assembler Block 15 C Code Microcontrollers #include "16F877A.h" #use delay(clock=4000000) #int_ext

Ngày đăng: 06/11/2017, 20:54

w