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.

EEPROM to TX

Status
Not open for further replies.

flemmard

New Member
Hi all,
I have 2 bytes stored in the EEPROM of PIC16f877.
Now, as soon as a push button is pressed , i wish to transfer the 2 byte contents of EEPROM in to TX and subsequently to RS232.

can you guys give me a rough routine to transfer content from EEPROM to TX?

Thaks
 
I thought one of the purposes of C for micros was to provide a pool from which simple routines may be sourced. C already has EEprom_Read() and SerialTX(), PutC(), Cputs(), or whatever proprietary function nomenclature dictated by the compiler at that particular build time. Just combine them.

Well anyway this is how the asm will most likely if not look like will do in the end anyway.

Code:
	Call 	Get2byteEEprom		;Get 2 precious bytes.
	Call 	SetupUsart		;Initial USART.
	movf 	eeprom_byte1, w		;--Moving First byte to USART TX--
	movwf 	TXREG
	Call 	WaitTillTXComplete
	movf 	eeprom_byte2, w		;--Moving Second byte to USART TX
	movwf 	TXREG
	Call 	WaitTillTXComplete
;This snippet took 10x longer to type
;than to conceive.  Type time ~ 1 minute.
 
Last edited:
donniedj said:
I thought one of the purposes of C for micros was to provide a pool from which simple routines may be sourced. C already has EEprom_Read() and SerialTX(), PutC(), Cputs(), or whatever proprietary function nomenclature dictated by the compiler at that particular build time. Just combine them.

Well anyway this is how the asm will most likely if not look like will do in the end anyway.

Code:
	Call 	Get2byteEEprom		;Get 2 precious bytes.
	Call 	SetupUsart		;Initial USART.
	movf 	eeprom_byte1, w		;--Moving First byte to USART TX--
	movwf 	TXREG
	Call 	WaitTillTXComplete
	movf 	eeprom_byte2, w		;--Moving Second byte to USART TX
	movwf 	TXREG
	Call 	WaitTillTXComplete
;This snippet took 10x longer to type
;than to conceive.  Type time ~ 1 minute.


This is my sample program to push those bits to TX.Once i tested with LED in the output pin, it glowed continuously .Was it because of high baud rate?Any alternate way to check my bits before actually connecting it to my PC?
Please enlighten me !
Thanks

Code:
#include <pic1687x.h>

// Transmitter test program


void main() {
TRISC = 0x00 ; //portC as output
	SPBRG = 129;	// Set the baud rate to 2.4k
	BRGH = 1;		// Set high baud rate 
	SYNC = 0;		// Set asynchronous 
	SPEN = 1;		// Enable serial port pins 
	TX9 = 0;		// Disable 9 bit transmission 
	TXIE = 0;		// Disable tx interrupts 
	RCIE = 0;		// Disable rx interrupts 
	TXEN = 1;		// Enable the transmitter

	while(1) {
		while(!TXIF) {	// Checks if the transmit flag is down 
			continue;
		}
		TXREG = 0b01010101;
	}
}
 
You will also need supporting hardware such as a MAX232 serial driver. This converts 0,v 5v TTL levels to -12v, +12v RS232 levels.

NittPitts:
Yeah I know what the actual range of RS232 levels are, but what does that matter here anyway, so lay off. :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top