Sameer Sathe of sameerksathe shares this code:
This is the code to actually enter the code into mcu via USART , it will only accept the code unless & until u only press capital 'S'. Without using any Interrupt , its a poleing type code+;-------------------------------------------------------------------------------------- USART_REC BANKSEL PIR1 btfss PIR1,RCIF ; Test for received data flag GOTO USART_REC_returns BTFSC RCSTA,OERR goto overerror ; check for over run error BTFSC RCSTA,FERR GOTO frameerror ; CHECK FOR FRAMING ERROR movf RCREG,W ; Store data in W MOVWF HAULT_KEY goto HAULT_DECIDE overerror bcf rcsta,cren ;pulse cren off... movf rcreg,w ;flush fifo movf rcreg,w ; all three elements. movf rcreg,w bsf rcsta,cren ;turn cren back on. ;this pulsing of cren ;will clear the oerr flag. ;enable interrupts. goto USART_REC ;try again... frameerror movf rcreg,w ;reading rcreg clears ferr flag. bsf intcon,gie ;enable interrupts. goto USART_REC ;try again... ;-------------------------------------------------------------------------------------------- HAULT_DECIDE ; CHECK IF THE KEY PRESSED ID 'S' OR RESUME NORMAL SEND DATA FUNCTION MOVLW 0X53 ; capital S SUBWF HAULT_KEY BTFSS STATUS,C goto USART_REC_returns BTFSS STATUS,Z goto USART_REC_returns continue to key enter routine
file: /Techref/microchip/serial-sameer.htm, 1KB, , updated: 2016/11/15 11:17, local time: 2024/11/8 14:23,
3.137.214.139:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.piclist.com/techref/microchip/serial-sameer.htm"> PIC RS232 routine</A> |
Did you find what you needed? |
PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
Welcome to www.piclist.com! |
.