![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| | |
| |
| | (permalink) | |
| Quote:
I need in C routine. Thanks | ||
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) | |
| Quote:
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;
}
} | ||
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| 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 |