Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 23rd September 2007, 06:40 AM   (permalink)
Default EEPROM to TX

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
flemmard is offline  
Old 23rd September 2007, 01:26 PM   (permalink)
Default

Go to http://www.winpicprog.co.uk/pic_tutorial.htm

Check out Tut5 and 7
gregmcc is offline  
Old 23rd September 2007, 03:47 PM   (permalink)
Default

Quote:
Originally Posted by gregmcc
Hi ,
I need in C routine.
Thanks
flemmard is offline  
Old 23rd September 2007, 06:35 PM   (permalink)
Default

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 by donniedj; 23rd September 2007 at 06:41 PM.
donniedj is offline  
Old 23rd September 2007, 07:25 PM   (permalink)
Default

Quote:
Originally Posted by donniedj
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;
	}
}
flemmard is offline  
Old 23rd September 2007, 09:29 PM   (permalink)
Default

Using an LED is not useful. Everything happens too fast. Use a logic probe or a scope. You can build a logic probe. should be many examples on the net of simple ones. If you are at a school they should have both.
3v0 is online now  
Old 26th September 2007, 01:58 AM   (permalink)
Default

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.
donniedj is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Spurious write or corrupting EEPROM ??? Mr.Anderson Micro Controllers 5 19th August 2006 02:33 AM
working with eeprom pages? justDIY Micro Controllers 1 7th October 2005 10:21 AM
sequential read to AT24C01A serial EEPROM giaracam Micro Controllers 2 26th October 2004 04:19 AM
Ext EEPROM read delay? brodin Micro Controllers 2 22nd February 2004 02:44 PM
Writing to EEPROM rizzy Micro Controllers 3 27th January 2004 05:01 AM



All times are GMT. The time now is 09:19 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker