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/12/25 18:16,
18.226.88.18:LOG IN
|
©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://massmind.org/techref/microchip/serial-sameer.htm"> PIC RS232 routine</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.