THỰC HÀNH VI XỬ LÝ - Khoa Khoa học và Kỹ thuật Máy tính
THỰC HÀNH VI XỬ LÝ - Khoa Khoa học và Kỹ thuật Máy tính
THỰC HÀNH VI XỬ LÝ - Khoa Khoa học và Kỹ thuật Máy tính
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Trường ĐH. Bách <strong>Khoa</strong> TP.HCM <strong>Khoa</strong> KH & KTMT<br />
BSF TRISC,7<br />
RETURN<br />
Bước 4: Khởi tạo các vector ngắt<br />
org 00000h ; Reset Vector<br />
goto Start<br />
org 00008h ; Interrupt vector<br />
goto IntVector<br />
Start<br />
GOTO<br />
IntVector<br />
RETFIE<br />
$<br />
Bước 5: Khởi tạo cho ngắt UART, tốc độ 9600baud tại tần số 4Mhz.<br />
INIT_UART<br />
MOVLW 19h ; 9600 baud @4MHz<br />
MOVWF SPBRG<br />
BSF TXSTA,TXEN ; Enable transmit<br />
BSF TXSTA,BRGH ; Select high baud rate<br />
BSF RCSTA,SPEN ; Enable Serial Port<br />
BSF RCSTA,CREN ; Enable continuous reception<br />
BCF PIR1,RCIF ; Clear RCIF Interrupt Flag<br />
BSF PIE1,RCIE ; Set RCIE Interrupt Enable<br />
BSF INTCON,PEIE ; Enable peripheral interrupts<br />
BSF INTCON,GIE ; Enable global interrupts<br />
RETURN<br />
Bước 6: Viết chương trình trong ngắt thực hiện nhiệm vụ nhận một dữ liệu<br />
từ máy <strong>tính</strong> truyền xuống sau đó gởi lại kí tự đó cho máy tình nhận lại.<br />
IntVector<br />
btfss PIR1,RCIF ; Did USART cause interrupt?<br />
goto ISREnd ; No, some other interrupt<br />
movlw 06h ; Mask out unwanted bits<br />
andwf RCSTA,W ; Check for errors<br />
btfss STATUS,Z ; Was either error status bit set?<br />
goto RcvError ; Found error, flag it<br />
Bộ môn <strong>Kỹ</strong> Thuật <strong>Máy</strong> Tính 67 Thực hành Vi xử lý