how to read sequnce of 2k chars from at89s52 flash

Status
Not open for further replies.

sagar474

Full Member level 5
Joined
Oct 18, 2009
Messages
285
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,123
I have to store 2000 chars while programming in at89s52 flash and display them successively on hyper terminal when program runs. is it possible and how.
 

Try sending those data sequentially as we do in a look-up table.

Use a reference variable (ref), then a base variable(base) and increment the reference variable to serially send all the data sequentially to PC.

for (ref=0;ref<200;ref++)
{
transmit (base + ref);
}

Transmit is sub routine to serially transmit the data.
Base is the location of the First Number of the complete series of 2000 numbers.

Try it.
 

You should be able to define a pointer of type char pointing to a string literal which is normally stored in Flash memory.


Code:
char * pStr = "Enter your 2000 characters as text here........";

You can then use the standard library routines to access the string literal by use of the pointer pStr.

Or access the string literal using your own UART routines which accept a pointer of type char, pStr.


BigDog

- - - Updated - - -

You could also save guard the pointer by making it constant as well:

Code:
char * [COLOR="#FF0000"]const[/COLOR] pStr = "Enter your 2000 characters as text here........";

Defining the pointer as a constant prevents its value from being unintentionally modified and potentially losing the address/location of the string literal.



The following, which also defines the object pointed to as constant, is valid, although somewhat redundant:

Code:
[COLOR="#FF0000"]const[/COLOR] char * [COLOR="#FF0000"]const[/COLOR] pStr = "Enter your 2000 characters as text here........";

Or

Code:
char [COLOR="#FF0000"]const[/COLOR] * [COLOR="#FF0000"]const[/COLOR] pStr = "Enter your 2000 characters as text here........";



BigDog
 
I have to store 2000 chars while programming in at89s52 flash and display them successively on hyper terminal when program runs. is it possible and how.


Go for this link :

In the program section you'll find serialprint() function.
Read this, may it can be helpful to you.


or read this doc.

View attachment 8051 & Hyper Terminal.pdf
 

thnakyou for your replay.
I haveing about 2000 char in a text file including "new line chars" how can i treat them all as a string.
 

Assuming no changes need to be made to the contents of the file.

One possible solution is making a copy of the file, adding the following to the beginning:

Code:
char * pStr = "

And the following to the end:

Code:
";

Then rename the file to 2kstring.h and simply include it appropriately as follows:

Code:
#include "2kstring.h"


If changes do need to be made to the contents of the file, then some word processing will need to be done.


I need to ask, why send the entire contents over the serial connection as one single transmission?

Two thousand characters exceeds the default scroll buffer of most terminal emulation apps, therefore in their default settings most users will not be able to scroll back to read the transmitted contents.

Why not break the two thousand characters into smaller sections?

Or is it an image, configuration file, crypto key or some other block of data which must be passed as a whole?


BigDog
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…