Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me fix a software UART routine for PIC18F452

Status
Not open for further replies.

saeed_pk

Full Member level 4
Joined
May 20, 2006
Messages
237
Helped
35
Reputation
68
Reaction score
28
Trophy points
1,308
Location
Islamabad, Pakistan
Activity points
2,655
I am about to use a software UART Routine on PIC18F452
This Routing is working well for PIC16F877A I am using PICC and PICC-18 Compiler for this purpose please
review the sourece code

Code:
#include <pic.h>
#ifndef RS232_H
#define RS232_H

//Defines

#define	CLEAR		0
#define	SET			1

//Modify these parameters for your device
//Main I/O
#define	RX			RC5
#define	TX			RC4
#define	RX_ASM		_PORTC,5
#define	TX_ASM		_PORTC,4
#define	TRIS_TX		TRISC4
#define	TRIS_RX		TRISC5


//Global Variable Declarations
unsigned char delayconstant,txreg,bitcount,rxreg,baudrate; 

//Function Prototypes
#endif

Function Definition file rs232.c is as under (I require inly serial reception)

Code:
#include "rs232.h"


unsigned char Receive()
{
	TRIS_RX = SET;
	
	delayconstant = baudrate;
	bitcount = 9;
	
	#asm
		
		btfsc	RX_ASM
		goto	$-1
		decfsz	_delayconstant,f
		goto	$-1
		movf	_baudrate,w
		movwf	_delayconstant
		decfsz	_bitcount,f
		goto	$+2
		goto	$+6
		bcf		_STATUS,0
		btfsc	RX_ASM
		bsf		_STATUS,0
		rrf		_rxreg,f
		goto	$-11
	#endasm

	return rxreg;
}

when i call this function in main function for PIC18F452 then it gives following errors

Error[000] C:\Documents and Settings\Administrator.EWI-ATACTS\Desktop\SOFT-ASm\rs232.obj 15 : Fixup overflow referencing psect bigbss (loc 0x118 (0x10A+14), size 1, value 0x5E7)
Error[000] C:\Documents and Settings\Administrator.EWI-ATACTS\Desktop\SOFT-ASm\rs232.obj 15 : Fixup overflow referencing psect bigbss (loc 0x11A (0x10A+16), size 1, value 0x5E9)
Error[000] C:\Documents and Settings\Administrator.EWI-ATACTS\Desktop\SOFT-ASm\rs232.obj 15 : Fixup overflow referencing psect bigbss (loc 0x11C (0x10A+18), size 1, value 0x5E8)
Error[000] rs232.rlf 35 : Fixup overflow in expression (loc 0x5EC (0x5EC+0), size 1, value 0x5E7)
Error[000] rs232.rlf 39 : Fixup overflow in expression (loc 0x5EC (0x5EC+0), size 1, value 0x5E9)
Error[000] rs232.rlf 43 : Fixup overflow in expression (loc 0x5EC (0x5EC+0), size 1, value 0x5E8)

please help me updating this function for PIC18F452 of Convert the assembly portion in C

Regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top