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.

16F88 serial comm

Status
Not open for further replies.

ttbuddy

New Member
OK ... i am serious here, please provide me with advice whether my assembly works for serial communication. It is basically a calculation on getting ampere hour. Here is the main part:

Code:
calc_Ah:
    add1632    Amps,AmpSum    ; AmpSum = accumulated Amps
    mov32    AmpSum,dd
    movi16    3600*3,aa    ; 3 reads per second, 3600 seconds per hour
    call    Div32        ; AmpHours = AmpSum  / (reads per hour)
store_Ah:
    mov16    dd+2,AmpHours

Code:
Show_AmpHours:
	mov16	AmpHours,Number
	call	bin2dec
	movlw	' '
	call	Print_Char
	call	ShowDec2	; display "xx.xx"
	movlw	'A'
	call	Print_Char
	movlw	'h'
	call	Print_Char
	return
And here is the assembly to display this value to the 16x2 LCD:
Code:
call    Show_AmpHours     ; "9999.9W 99.99Ah"

Now I try to send Show_AmpHours as a serial data to my RF module.
The RF module is using a BR of 9600, 8N1 setting.

And here is my attempt to send it in assembly. Please, I am a truely newbie on assembly.
I am using 16F88.

Code:
send	movwf	TXREG
	banksel	TXSTA		;bank 1

wait         btfss   TXSTA,TRMT	;loop until this bit gets set
                goto    wait		;when the shift register has been emptied 
	banksel	PORTA		;bank 0
	return


serial
	banksel	SPBRG		;bank 1
	movlw 	.25 		;set baud rate
	movwf 	SPBRG
	movlw 	b'00100100'	;8-bit transmit, transmitter enabled,
	movwf 	TXSTA 		;asynchronous mode, high speed mode
	banksel	PORTA		;bank 0
	movlw 	b'10010000'	;8-bit receive, receiver enabled,
	movwf	RCSTA 		;serial port enabled

message	movlw	AmpereHours		;send: 16F88 alive	
                call	send
                movlw	0x0d		;CR
	call	send

I refer this code from other site and modify it a bit. Might want to know is the code correct?
Thanks, i really appreciate ur help.
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top