Just make the buffer larger than 128 bytes, where is your problem with that?
In line 312 you get a warning which is indeed an error! A uint8 is always smaller than 256, so it is an endless loop.
NEVER declare a loop variable (i) as global when not in absolute need. When you do not want that the var allocatesd automatically (which is the default), declare it as "static".
thanks a lot Bob. I changed the i declaration to uint16 i. the program is working fine for 256 bytes. when i did for 512 bytes - the data on hyperterminal comes overlapping in peices.
i have to transfer total 239535 bytes? what should be the approach?
Transfering your bytes is not all you have to do, you have to process your data which means that you have to transmit them after receiving. You can do that by processing the data in small chunks in a loop. A more advanced (and more difficult to program) is the method which is using two buffers, one to store the data in and one you transfer data from. This only makes sense when interrupt driven.
As Bob states, you need to process the data from the UART
remember that the write cycle time of a EEPOM is in the range of 2-5ms. Take 5ms for now.
writing 256 byte means 1.3 second. just for the writing to the EEPROM. ( yes the SPI interface is much faster, but you still need to wait for the chip to finish writing the data).
If your program is to recive 256 byte from UART than write 256 byte to EEPROM, then you have to send 256 byte and wait 1.3 second before sending the other 256 bytes.
If you use two recive buffer, you can use 2nd buffer while writing using the 1st buffer but you still limited by the speed of the EEPROM.
BTW can you tell us what chips you use, so we can see what timing it needs to be.
Also if you can use SPI flash and it should be faster with page write/program mode.
There seems to have issues with the way you wirte to the EEPROM as well, but lets fix the the timing issue first.
thanks all for inputs. i am now using two buffers one for filling data from uart and one to write data on eeprom. now some data is getting missed in between for 2048 bytes program .
1. do i need to introduce delay.
2. even if i set 2400 bps on uart at psoc creator and hyperterminal some bytes getting missed.
If your buffer is 128 bytes, worst case EEPROM erase/write cycle is 20 ms per
row, row size is 16 bytes, so thats 20 mS X (128 / 16 ) = 160 mS to dump the whole
Of course you have to factor in the clock tolerance as that effects the actual time
you will erase/write. If IMO at 48 Mhz thats 10% of variation.
Did you change to a new program? you either use interrupt on the UART received or increase the buffer size of the uart RX.
With 2400bps, and using 8N1, each byte would be 3.8ms, and the cycle time of a 20ms means you will have 5 to 6 bytes from UART.
the chip is :- 8 Mbit SPI Serial flash
chip erase 50 ms
write/byte program - 10us
read - 33 MHz
till 2048 bytes prog is working fine . but for 4096 bytes the read is returning garabage values.
You are leading us to guess what works and what may be a cause for an error. Quite more informative for us would be when you post your complete project here. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
i am using 2 buffers to transmit and receive data for writing on eeprom. the program is working fine for multiple of 512 bytes data till 262144 bytes ie 256 kb. but the actual data is 239535 bytes. can anybody suggest how to use end of file/transmission or any other approch in hyperterminal?