ARRAYS in supplementary code
Moderator: Benj
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
ARRAYS in supplementary code
Hi,
I would like to create some Arrays in C code that can be called as required.
I am very conscious of the RAM that i am using so i dont want to have all of the arrays stored in RAM.
When adding arrays in supplementary code are these stored in the RAM or in the FLASH memory?
If they arent stored in the FLASH is there a way to define them in the chart but only have them used in the RAM when they are written into an array?
I would like to create some Arrays in C code that can be called as required.
I am very conscious of the RAM that i am using so i dont want to have all of the arrays stored in RAM.
When adding arrays in supplementary code are these stored in the RAM or in the FLASH memory?
If they arent stored in the FLASH is there a way to define them in the chart but only have them used in the RAM when they are written into an array?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ARRAYS in supplementary code
Hello,
Can you use the LUT component available under storage, this effectively creates a ROM based array you can call directly within the flow chart.
Can you use the LUT component available under storage, this effectively creates a ROM based array you can call directly within the flow chart.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: ARRAYS in supplementary code
It has just started coming back to me. I have done this before on PIC.
So i just added this to supplementary code
I thought this would compile OK. But i get this error.
Q1 TEST.c:344:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char'
rom char* BATTERY4 = {0xFF , 0x8F , 0x00, //LED 1 ORANGE
I cant see anything wrong, no missing commas etc. Any ideas?
So i just added this to supplementary code
Code: Select all
//LED BATTERY PROFILE 4
rom char* BATTERY4 = {0xFF , 0x8F , 0x00, //LED 1 ORANGE
0xFF , 0x8F , 0x00, //LED 2 ORANGE
0xFF , 0x8F , 0x00, //LED 3 ORANGE
0x00 , 0x00 , 0x00, //LED 4 OFF
0x00 , 0x00 , 0x00}; //LED 5 OFF
Q1 TEST.c:344:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char'
rom char* BATTERY4 = {0xFF , 0x8F , 0x00, //LED 1 ORANGE
I cant see anything wrong, no missing commas etc. Any ideas?
- Bachman
- Posts: 116
- Joined: Sun Sep 07, 2014 11:37 am
- Location: Hungary
- Has thanked: 9 times
- Been thanked: 53 times
- Contact:
Re: ARRAYS in supplementary code
Maybe:
Code: Select all
const rom unsigned char BATTERY4[]={
0xFF , 0x8F , 0x00, //LED 1 ORANGE
0xFF , 0x8F , 0x00, //LED 2 ORANGE
0xFF , 0x8F , 0x00, //LED 3 ORANGE
0x00 , 0x00 , 0x00, //LED 4 OFF
0x00 , 0x00 , 0x00}; //LED 5 OFF
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ARRAYS in supplementary code
This should work, It's what the Lookup table component generates.
Code: Select all
const unsigned char BATTERY4 [] =
{
0xFF , 0x8F , 0x00, //LED 1 ORANGE
0xFF , 0x8F , 0x00, //LED 2 ORANGE
0xFF , 0x8F , 0x00, //LED 3 ORANGE
0x00 , 0x00 , 0x00, //LED 4 OFF
0x00 , 0x00 , 0x00 //LED 5 OFF
};
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: ARRAYS in supplementary code
I'm using 47K of bytes within supplementary code as loading images
The only way all 47K could be loaded was by using the format:
Any other way would cause a ran out of memory issue.
For example if you have lots of data then:
Does not place data in ROM, it places it in RAM instead.
Funny how it all works.
The only way all 47K could be loaded was by using the format:
Code: Select all
char const unsigned BATTERY4[] ={0xFF , 0x8F , 0x00, //LED 1 ORANGE
0xFF , 0x8F , 0x00, //LED 2 ORANGE
0xFF , 0x8F , 0x00, //LED 3 ORANGE
0x00 , 0x00 , 0x00, //LED 4 OFF
0x00 , 0x00 , 0x00 //LED 5 OFF
};
For example if you have lots of data then:
Code: Select all
const unsigned char BATTERY4[] =
Funny how it all works.
Martin
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: ARRAYS in supplementary code
medelec35 wrote: ↑Wed Sep 16, 2020 12:27 amI'm using 47K of bytes within supplementary code as loading images
The only way all 47K could be loaded was by using the format:Any other way would cause a ran out of memory issue.Code: Select all
char const unsigned BATTERY4[] ={0xFF , 0x8F , 0x00, //LED 1 ORANGE 0xFF , 0x8F , 0x00, //LED 2 ORANGE 0xFF , 0x8F , 0x00, //LED 3 ORANGE 0x00 , 0x00 , 0x00, //LED 4 OFF 0x00 , 0x00 , 0x00 //LED 5 OFF };
For example if you have lots of data then:Does not place data in ROM, it places it in RAM instead.Code: Select all
const unsigned char BATTERY4[] =
Funny how it all works.
Hi,
I tried Bens example and this compiles fine now.
I have just seem your post this morning, medelec35.
so i have this correct....
Code: Select all
char const unsigned BATTERY4[] =
Code: Select all
const unsigned char BATTERY4 [] =
How do i know for sure where its being placed? Can i check this sort of thing somehow?
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: ARRAYS in supplementary code
I'm not sure in the answer.
It was LeighM that said to use Since I was requiring lots of data.
He will know far more than me.
The topic is in a hidden section of the forum for staff and VC members.
I have moved it to the public section for other people to learn from.
Here is the link
Rereading the topic.
The other way the data is not stored in RAM, but is treated as a RAM variable.
Note: Started out with AVR and ended up with PIC, so both are covered in the topic.
Hope you find the reading useful?
It was LeighM that said to use
Code: Select all
char const unsigned
He will know far more than me.
The topic is in a hidden section of the forum for staff and VC members.
I have moved it to the public section for other people to learn from.
Here is the link
Rereading the topic.
The other way the data is not stored in RAM, but is treated as a RAM variable.
Note: Started out with AVR and ended up with PIC, so both are covered in the topic.
Hope you find the reading useful?
Martin