14 Replies Latest reply on Oct 17, 2014 12:53 AM by userc_40762

    bufer data size

      how can i store data greater than 128 bytes in buffer?

        • 1. Re: bufer data size

          Just make the buffer larger than 128 bytes, where is your problem with that?

          uint8_t buffer[256];

          should work.

          • 2. Re: bufer data size

             i have attached the code. tx buffer is working fine til 128 size but 256 is not working

            • 3. Re: bufer data size

              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".





              • 4. Re: bufer data size

                 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?

                • 5. Re: bufer data size

                  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.





                  • 6. Re: bufer data size

                     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.

                    • 7. Re: bufer data size

                       There seems to have issues with the way you wirte to the EEPROM as well, but lets fix the the timing issue first.

                      • 8. Re: bufer data size


                        • 9. Re: bufer data size

                           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.

                          • 10. Re: bufer data size

                            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.




                            Regards, Dana.

                            • 11. Re: bufer data size

                              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.  

                              • 12. Re: bufer data size

                                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.

                                • 13. Re: bufer data size

                                  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.





                                  • 14. Re: bufer data size

                                    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?