Hi.
I must create an array of bytes of 7000 elements. Also constant of array is ok.
I use the PIC 18F452.
How can i store so much data with Great Cow Basic?
Thank you very much.
Giovanni
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The 18F452 has 1536 bytes of RAM. Some of which will be used by varialbes and therefore it is not possible to use a dynanic array of 7000 elements in 1536 bytes.
So, you need to use a different approach. You will have to use PROGMEM as your array memory. This is slower than RAM but can work on these small memory chips. You will need to use ProgramWrite (with ProgramErase) to create and update, and, use ProgramRead to read. You will need to create a 32 byte buffer to support this activity.
BUT, what is the 7000 byte array doing? We may be able to advise if you tell us what you are up to.
OR, you can simple buy a chip that works for you. You are aware that Microchip would not recommend the 18f452 for new projects. So, I would advise the PIC18F47K42 it has 8192 bytes of RAM and I am assuming that the other variables will be fit.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok. Anobium - Thank you very much for your suggestion.
I will try it.
I am storing the 7000 samples of a phrase to let to speech the PIC. This project of mine was published on the italian magazine "Fare Elettronica".
I already done this but now i want to reproduce a longer phrase.
Ok, thank you very much!!!!
Giovanni
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just a quick note which may be useful. It is possible to have your program report the size of the table for you. That way you wouldn't need to use a fixed value in your For...Next loop.
TableValoriasByte11712712723873.......EndTabledimkaswordDimTableLenAsWordReadTableValori,0,TableLen'Get the length of the tablefork=1toTableLenReadTableValori,k,Lettoportb=Lettowait167usnextk
If you added or removed items in the table, your code will automatically adjust to the new length of the table.
Last edit: mkstevo 2019-09-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
I must create an array of bytes of 7000 elements. Also constant of array is ok.
I use the PIC 18F452.
How can i store so much data with Great Cow Basic?
Thank you very much.
Giovanni
You create the array and access the elements.
What have you tried? or, is this a 'how do I create an array?'
Hi.
Thank you.
I create the array with this:
dim MyArray(7000) as byte
MyArray(1)=120
MyArray(2)=220
MyArray(3)=40
MyArray(4)=88
MyArray(5)=12
MyArray(6)=46
MyArray(7)=87
MyArray(8)=13
MyArray(9)=77
......
......
.......
Of course, the error is:
Error: The array MYARRAY is too large
Thank you
GIovanni
The 18F452 has 1536 bytes of RAM. Some of which will be used by varialbes and therefore it is not possible to use a dynanic array of 7000 elements in 1536 bytes.
So, you need to use a different approach. You will have to use PROGMEM as your array memory. This is slower than RAM but can work on these small memory chips. You will need to use ProgramWrite (with ProgramErase) to create and update, and, use ProgramRead to read. You will need to create a 32 byte buffer to support this activity.
BUT, what is the 7000 byte array doing? We may be able to advise if you tell us what you are up to.
OR, you can simple buy a chip that works for you. You are aware that Microchip would not recommend the 18f452 for new projects. So, I would advise the PIC18F47K42 it has 8192 bytes of RAM and I am assuming that the other variables will be fit.
Ok. Anobium - Thank you very much for your suggestion.
I will try it.
I am storing the 7000 samples of a phrase to let to speech the PIC. This project of mine was published on the italian magazine "Fare Elettronica".
I already done this but now i want to reproduce a longer phrase.
Ok, thank you very much!!!!
Giovanni
Hi
I have solved with Lookup Table, in effect
i must only read the values, not write them.
==========================
Table Valori as Byte
117
127
127
23
87
3
.......
End Table
dim k as word
for k=1 to 7721
ReadTable Valori, k, Letto
portb=Letto
wait 167 us
next k
==========================
Thank you to every body!!!
Giovanni
Just a quick note which may be useful. It is possible to have your program report the size of the table for you. That way you wouldn't need to use a fixed value in your For...Next loop.
If you added or removed items in the table, your code will automatically adjust to the new length of the table.
Last edit: mkstevo 2019-09-21
@MKStevo - nice! Will add this to the FAQ!
A FAQ Entry needs a question
Suggestions?
Or how about a snippet Entry?
I published this:
http://gcbasic.sourceforge.net/Typesetter/index.php/FAQ (Last Entry) Improvements, complaints? report to me :-)
:-) Love it.