Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Software Uart and 12f508

Status
Not open for further replies.

be80be

Well-Known Member
Software Usart and 12f508 I was bored and been reading about backdoors. To send data out serial just using simple delays and software Usart. So i wiped this up.

It works and only using 65 of 512 program memory and 3 of 25 data.
You could use it dump some values

Code:
 ;**********************************************************************
;                                                                     *
;    Filename:	    serial.asm                                        *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:   Burt E Ratliff                                         *
;    Company:                                                         *
;                                                                     * 
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P12F508.INC                                      *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************

	list      p=12F508            ; list directive to define processor
	#include <p12F508.inc>        ; processor specific variable definitions

	__CONFIG   _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC

; pin assignments
    #define     RX   GPIO,0      ; receive pin on GP0
	#define 	TX	 GPIO,1		 ; transmit pin on GP1



;***** VARIABLE DEFINITIONS
      UDATA
	buffer     res    1            
	counter    res    1 
	Count      res    1 


;**********************************************************************


; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.

RESET   CODE    0x000           ; effective reset vector
        movwf   OSCCAL          ; update OSCCAL with factory cal value 
    
    goto    init              ; jump to main program
init 
	movlw b'00000001'		  ; set I/O
    tris    GPIO
	bsf 	TX
	movlw	'b'               ; sets text to loads buffer with 
	call	start
	movlw	'e'
	call	start
	movlw	'8'
	call	start
	movlw	'0'
	call	start
	movlw	'b'
    call	start
	movlw	'e'
    call	start
	movlw	' '
	call	start
	movlw	'w'
	call	start
	movlw	'a'
	call	start
	movlw	's'
	call	start
	movlw	' '
	call	start
	movlw	'h'
	call	start
	movlw	'e'
	call	start
	movlw	'r'
	call	start
	movlw	'e'
	call	start
	movlw	0x0A
	call	start
	movlw	0x0D
	call	start
    goto	init		  ;loop for ever
			
start	
	movwf buffer
	movlw 0x08
	movwf counter        ; counts the 8 bits 
    bcf   TX             ; set TX low
    call  BItdelay       ; delay to get a 9600 bit rate
TXLoop  
    rrf   buffer ,f      ;send one bit
    btfss STATUS ,C      ;  
    bcf   TX             ;
    btfsc STATUS ,C		 ;
    bsf   TX			 ;
    call  BItdelay		 ;
    decfsz counter,f     ;test if all done
    goto  TXLoop		 ;
    bsf   TX			 ;
    call  BItdelay		 ;
    return
BItdelay                 ; timing delay 
    movlw 0x18
    movwf  Count  
Wait    
    nop 
    decfsz Count ,f
    goto   Wait
    return 

	END  ; directive 'end of program'
 
Here's an even smaller one that was used in this thread. Anyone interested in getting the most from these little chips should read the first 5 pages.
Code:
;
;  19200 baud, exact 52-usec bit timing (4 MHz)
;
Put232  bsf     GPIO,TxPin      ; send start bit
        movwf   OwTemp          ; save Tx data
        movlw   9               ; 8 data bits + 1 stop bit
        movwf   BitCtr          ; update bit counter
PutBit  setc                    ; shift in stop bits
        movlw  (52-8)/4         ; 52 usecs - 8 usec loop time
        movwf   temp            ; a 4 cycle (4 usec) loop
        decfsz  temp,W          ; W == 0? yes, skip, else
        goto    $-2             ; loop
        rrf     OwTemp,F        ; put data bit in C (W = 0)
        skpc                    ; a '1' bit? yes, skip, else
        iorlw   1<<TxPin        ; send a '0', W = 1<<TxPin
        movwf   GPIO            ; send bit, clear OwPin
        decfsz  BitCtr,F        ; all 9 bits? yes, skip, else
        goto    PutBit          ; send next bit
        retlw   0x0A            ; return <lf> char

Just 16 program words used.

Mike.
 
Last edited:
Thanks Mike I could of saved some time if i new you had posted the One Wire Temperature sensor just had a look nice work.

I just had some 12f508 chips in a bunch of junk was cleaning my desk, And I read some stuff last night how to code backdoors for a Z80 figured may as well try it out on a 12f508 you have to love them small chips. First thing I did was erase the ocscal setting. Couldn't figure how I did that. I hooked mclr to wrong place LOL.

Thanks agin for the post I'm going to read all of now. I hope you have a good year Mike. big 2011 never figured I would see that LOL
 
Hi Burt,

Happy New Year.

It was a fun project to do and myself and Mike (K8LH) had fun optimizing it.

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top