Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

UART String Where to Save?

Status
Not open for further replies.

Suraj143

Active Member
I'm receiving a string of characters from a PC to PIC UART.Maximum length of a string is 200 characters (It can vary the length below 200).

I want to save these characters inside the PIC & must call back them for later use.

Note that my Bank0 & Bank1 GP registers all are used for a different task.

My question is where do I save these incoming string?I don't like to add another I2C memory chip, I want to do with a single PIC.

PIC16F88, Baud = 9600, OSC=4Mhz
 
Last edited:
You can save it in RAM. Using banks 3 and 4 gets you 192 locations. Add 8 of the common locations (0x70-0x77) and it will all fit in banks 3 and 4.

Mike.
 
Oops sorry mike I missed one thing.

I also used all the registers in the common area 0x70-0x7F.

I'm planing to save them in the flash memory while in the ISR routine when a character received.I don't know will this writing time affect to the next incoming character??

Also 16F88 pointed it can write to flash with 4 words but In my case I want to write one byte per time not 4 bytes.

Actually I need to save 7 bits data not 8 bits.
 
Last edited:
You will have a problem writing to flash as it stops the processor for up to 4mS in which time 4 characters could have arrived.

As you only need to store 7 bits why not write the first character to 7 locations and add the other 7 characters. This will store 8 values in 7 locations and enable the string to fit in banks 3 & 4. Once received you could then write it to flash if you wished. Eight characters will fit in 4 flash locations.

Mike,
 
As you only need to store 7 bits why not write the first character to 7 locations and add the other 7 characters. This will store 8 values in 7 locations and enable the string to fit in banks 3 & 4.

Mike can you explain a bit more!!
You mean when you receive character "A" save it into 7 locations??What you mean by adding?
 
I have a simple answer:- Use a different PIC.

The 16F88 has 368 bytes of storage. At first sight that looks fine for 200 bytes of data. However, that 368 bytes is in 5 different places:-
0x020 - 0x06f
0x0A0 - 0x0ef
0x110 - 0x16f
0x190 - 0x1ef
and finally the 0x070 to 0x07f common registers.

You would need to use at least 3 of those areas, and you can't even do indirectly without messing around with the banking bits, because the FSR is only 8 bits so it can only access 0x000 to 0x0ff, and then you set the IRP bit, and it accesses 0x100 to 0x1ff.

And if you start that, you'll bump into the fact that the 16F88 can't even access its whole program space with goto or call commands.

What you want is a PIC that can do the job easily. The 18F series also have 8 bit registers, but they have banks of 256 bytes that can be accessed with a simple pointer, so your 200 bytes can all be handled in the same way. You also have 3 indirect pointers, so you can probably leave one for accessing the USART data, or even one to store the data and one to retrieve it.

Even better, use the 24F series. They have 4096 bytes of data or more, and with 16 bit registers that you can use as pointers, you can access whatever you want so much more easily.

You haven't said what you are using the data for. When you are receiving serial data, there is loads of time to process that data as it comes in. It can be that you can store what you need from the data as it arrives, even if you have to discard that later if the end of the data says that you don't need it.
 
The "enhanced" mid-range 16F1827 might be a good candidate too. 384 bytes of RAM which can be addressed as contiguous memory (indirectly). Some other extremely nice features in the "enhanced" devices too.

Cheerful regards, Mike
 
Mike can you explain a bit more!!
You mean when you receive character "A" save it into 7 locations??What you mean by adding?

I mean that the first character gets shifted into bit 7 of 7 locations and then you OR in the next 7 characters into the lower bits of the same 7 bytes. It's messy but will enable you to fit it in.

Mike.
 
Ok guys now I understood.At first my PIC choice was not good.Its better to choose a correct PIC before designing a project.

Diver300 a very clever explanation that opened my eyes to shift to another PIC.

Mike, K8LH a very nice PIC,it has more options than some of 18F series chips.Unfortunately it is still not available in most suppliers.
 
Last edited:
I mean that the first character gets shifted into bit 7 of 7 locations and then you OR in the next 7 characters into the lower bits of the same 7 bytes. It's messy but will enable you to fit it in.

Now I understood mike thanks.
 
Status
Not open for further replies.

Latest threads

Back
Top