Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 12th June 2004, 02:05 PM   (permalink)
Default

Thanks Exo!! But how can I know whether my PIC enough RAM to store the samples? For example, if I need 128 samples, how many RAM do i need? :roll:
km is offline  
Old 12th June 2004, 02:12 PM   (permalink)
Default

Quote:
Originally Posted by km
if I need 128 samples, how many RAM do i need? :roll:
If a sample is 8 bit then you need 128 bytes of ram,
for 16 bit samples you would need 256 bytes, and so on
Exo is offline  
Old 12th June 2004, 04:55 PM   (permalink)
Default -

Quote:
Originally Posted by Exo
If a sample is 8 bit then you need 128 bytes of ram,
for 16 bit samples you would need 256 bytes, and so on
I a bit confused.:? Can you explain to me by how many samples? eg: 256 samples are suitable for how many byte of RAM?
km is offline  
Old 12th June 2004, 05:10 PM   (permalink)
Default Re: -

Quote:
Originally Posted by km
Quote:
Originally Posted by Exo
If a sample is 8 bit then you need 128 bytes of ram,
for 16 bit samples you would need 256 bytes, and so on
I a bit confused.:? Can you explain to me by how many samples? eg: 256 samples are suitable for how many byte of RAM?
One 8 bit sample will fit in one byte of RAM, filling it completely. So for 16 bit samples you need two bytes of RAM. If you use 10 bit samples, these also will not fit in one byte - so you would probably need to use two byes (or you can join them together, storing four 10 bit samples in five bytes).

Presumably you will probably be using an 8 bit sample?.

Also bear in mind that PIC RAM is in a number of different banks, if you are using large amounts of RAM you will have to select between banks accordingly.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 12th June 2004, 07:49 PM   (permalink)
Default -

:wink: Thanks Nigel, I get the idea now!! YES! I'm using 8-bit sample.
Quote:
Originally Posted by Nigel Goodwin
Also bear in mind that PIC RAM is in a number of different banks, if you are using large amounts of RAM you will have to select between banks accordingly.
What do you mean by "have to select between banks accordingly"? :?:
km is offline  
Old 12th June 2004, 08:28 PM   (permalink)
Default Re: -

Quote:
Originally Posted by km
What do you mean by "have to select between banks accordingly"? :?:
Pic's of the 16F range can only access 127 bytes of RAM at once so their memory is divided into banks. You will have to switch between banks to access each block of 127 bytes...
Exo is offline  
Old 12th June 2004, 10:13 PM   (permalink)
Default Re: -

Quote:
Originally Posted by Exo
Pic's of the 16F range can only access 127 bytes of RAM at once so their memory is divided into banks. You will have to switch between banks to access each block of 127 bytes...
Except it's not quite as simple as that :cry:

The special function registers are addressed in the same banks of memory, so you don't get 127 bytes of RAM in a single bank.

For an example, the 16F628A (whose datasheet happens to be in front of me) has 224 bytes of RAM (GPR's).

80 bytes in bank 0.
80 bytes in bank 1.
48 bytes in bank 2.
0 bytes in bank 3.

These only add up to 208 bytes, the other 16 bytes are common to all 4 banks, and are the top 16 bytes of the 127 byte space.

This is all explained in the datasheet.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 14th June 2004, 10:35 AM   (permalink)
Default -

Hi Nigel, just want to get some advice from you. :idea: For my project, I will need 128 samples (at least) to give a sufficiently accurate reading. As for the ADC resolution, 8-bit is OK. So, the PIC 16F628 and the A2D TLC 548 (8-bit resolution) will cause any problem? :roll:
km is offline  
Old 14th June 2004, 10:53 AM   (permalink)
Default Re: -

Quote:
Originally Posted by km
Hi Nigel, just want to get some advice from you. :idea: For my project, I will need 128 samples (at least) to give a sufficiently accurate reading. As for the ADC resolution, 8-bit is OK. So, the PIC 16F628 and the A2D TLC 548 (8-bit resolution) will cause any problem? :roll:
Only the problems of memory paging, you will need to use at least two memory pages to get 128 bytes. If 80 bytes was enough, you could use a single memory page.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 14th June 2004, 11:09 AM   (permalink)
Default -

Quote:
Originally Posted by Nigel Goodwin
Only the problems of memory paging, you will need to use at least two memory pages to get 128 bytes. If 80 bytes was enough, you could use a single memory page.

What do you mean by memory paging? (is it the different of banks you mentioned earlier) :roll: - Do I need to change the use of another PIC? If YES, can you please recommend me one? (without a built-in A2D) Thank you :wink:
km is offline  
Old 14th June 2004, 11:16 AM   (permalink)
Default

Quote:
Originally Posted by km
Quote:
Originally Posted by Nigel Goodwin
Only the problems of memory paging, you will need to use at least two memory pages to get 128 bytes. If 80 bytes was enough, you could use a single memory page.

What do you mean by memory paging? :roll: - Do I need to change the use of another PIC? If YES, can you please reccomend me one? (without a built-in A2D) Thank you :wink:
As I explained above, PIC memory is arranged in a number of banks, four in the case of the 16F628A - none has more than 80 bytes of memory (or 96 bytes, counting the 16 bytes common to all banks).

You need to select which bank you want to use, bank 0 being the default, for your purposes you will have to switch banks during reading and writing memory. It's all explained in the datasheets!.

AFAIK all mid-range PIC's work like this, I think high-range ones have more 'user friendly' memory.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 16th June 2004, 07:02 AM   (permalink)
Default -

Thanks for your reply Nigel :wink:

Quote:
Originally Posted by Nigel Goodwin
You need to select which bank you want to use, bank 0 being the default, for your purposes you will have to switch banks during reading and writing memory. It's all explained in the datasheets!.
Is it mean that I have to store the first 80 bytes of samples in bank 0 then for the next 48 bytes of samples I can store in either bank 1 or bank 2?

By the way, is there any differences between PIC 16F628-04/P & PIC 16F628-20/P :?:
km is offline  
Old 16th June 2004, 07:14 AM   (permalink)
Default Re: -

Quote:
Originally Posted by km
Thanks for your reply Nigel :wink:

Quote:
Originally Posted by Nigel Goodwin
You need to select which bank you want to use, bank 0 being the default, for your purposes you will have to switch banks during reading and writing memory. It's all explained in the datasheets!.
Is it mean that I have to store the first 80 bytes of samples in bank 0 then for the next 48 bytes of samples I can store in either bank 1 or bank 2?
Yers, or some variation on that!.

Quote:
By the way, is there any differences between PIC 16F628-04/P & PIC 16F628-20/P :?:
Only the guaranteed oscillator speed, but I've never seen (or heard of) any problems running 04 chips at 20MHz.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 18th June 2004, 09:50 AM   (permalink)
Default -

Quote:
Originally Posted by Nigel Goodwin
For an example, the 16F628A (whose datasheet happens to be in front of me) has 224 bytes of RAM (GPR's).

80 bytes in bank 0.
80 bytes in bank 1.
48 bytes in bank 2.
0 bytes in bank 3.

These only add up to 208 bytes, the other 16 bytes are common to all 4 banks, and are the top 16 bytes of the 127 byte space.
Is it compulsory to include the 16 bytes when storing the samples into the RAM? :roll:
km is offline  
Old 18th June 2004, 11:01 AM   (permalink)
Default Re: -

Quote:
Originally Posted by km
Is it compulsory to include the 16 bytes when storing the samples into the RAM? :roll:
You can include them or not, it's up to you, but as they are common to all banks it's probably better to use them for something else rather than waste them as plain storage - an obvious use for some of them would be as indexes into the ram buffer.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:11 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker