bufer data size

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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

0 Likes
14 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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

   
uint8_t buffer[256];
   

should work.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 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?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 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.

0 Likes
Anonymous
Not applicable

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

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

0 Likes
Anonymous
Not applicable

 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.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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

   

buffer.

   

 

   

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.

0 Likes
Anonymous
Not applicable

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.  

0 Likes
Anonymous
Not applicable

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

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?

0 Likes