Binary Numbers in Progmem array....

I have 2 tables one is stored in progmem and the other is stored in regular ram, and well i have now run ou of ram so something has to be done.

This code drives a hard wired 20x8 LED matrix...

BEFORE ALL THE CRITICISM: this is the way i would like to do this, and i am working on figuring out how to do it, in actuality i have working code but it is hugely bloated, I HAVE NO INTEREST in using a max 7219, or shift registers, this is an excersize in using all the available resources that would other wise be wasted. I am using a mega becasue i need multiple hardware serial ports, and 16 adcs ...

the arrays store character maps for the Matrix characters so it can scroll its message. the only thing icurrently need to know

Cont int:

Progmem

i would have pasted the code here but its over 9k characters.

the whole code is :

I have tried the progmem with both the 'B' modifier on the values and off , if i leave it out and use cont int it messes up, if i put the 'B; in and use const int, it works like a charm, either ways i do it in PROGMEM it doesn't work correctly ...

i would have pasted the code here but its over 9k characters.

Well, good luck getting answers on pastebin. If you want help HERE, you'll read the stickies at the top of the forum and figure out how to post your code HERE.

yeah, um like i said , you can oly post 9000 characters how do you propose that i post it here?

ive read the stickies, and they havent changed

i made an informative subject, i have described my product in detail, it does not relate to hardware, outside of a bunch of LEDS, would you like the datasheet on them?, they are connected common cathode style, columns to pins 22-41, rows to 42-49, I POSTED THE CODE THE ONLY WAY IT WILL GO INTO A FORUM POST... it doesnt fit in code blocks, i have no error, there is no minimal version of the code in question, if youd like me to abbreviate it then ok, but if the error is in the lines that are missed then i guess that will be my fault too.. there is no debuggng information, becasue i dont have an external logic analyzer, as far as what does work, everything when i have a huge amount of const int, nothing works when i put it in progmem, it lights up leds but it does not diplay characcters anymore. I am trying to scroll characters on the leds, its not that in depth, basically i have made a matrix equivelent to a GLCD, I didnt double post...

const PROGMEM int CharData[][8] = { // Character positions are ASCII + 1 int
{B00000000, B00000000, B00010000, B00010000, B01111100, B00010000, B00010000, B00000000, },
{B00000000, B00000000, B00010000, B00010000, B00010000, B00010000, B00000000, B00000000, },
};
const int CharData[][8] = { // Character positions are ASCII + 1 int
  {B00000000, B00000000, B00001000, B00001000, B00111110, B00001000, B00001000, B00000000}, //+
  {B00000000, B00000000, B00000000, B00000000, B00111100, B00000000, B00000000, B00000000}, //-
};

which is i guss a half a// version, i included the entire code becasue alot of the time helpful people have a good different way to do things i have helped people look at it another way before, sometimes a spare set of eyes is great., Pastebin was designed for this ... and perhaps the issue i am having should be in the documentation for arduino and then i would have to ask this question, what variable types can be sotred in progmen would be an amazing article.... JS

you can oly post 9000 characters

Your post can only contain 9000 characters. Plus attachments.

Read the stickies. If you are too impatient to absorb it all, at least search for “Additional Options”.

is there any oher way i can accomodate anyone to get help?

SkyNetDuino112.ino (87 KB)

tbillion:
....

is there any oher way i can accomodate anyone to get help?

Thanks for getting things straightened out. One more thing that would help understand the project, is a schematic or wiring diagram to show how the LED's are connected. I have also pondered using all the Mega pins for something like that before, just never got around to it.

Its gonna take me an hour, ill be back with a schematic… you want the 3d models for the housing too, or… cuz i mean they are too big for upload and god for bid you have to open an external link… LMAO

tbillion:
Its gonna take me an hour, ill be back with a schematic... you want the 3d models for the housing too, or... cuz i mean they are too big for upload and god for bid you have to open an external link.. LMAO

No the 3d models don't help me much. LOL

schematic.

matrix.PDF (237 KB)

This may or may not be helpful. It’s how the LCD custom characters are put into PROGMEM in my sketch.

typedef struct {
  byte pixelDef[8];
} oneCustomChr;
const byte customChr_s = sizeof (oneCustomChr);

enum  {ramUp_custom, ramLd_custom, ramDn_custom, rotateLeft_custom, rotateRight_custom,
       customA, customM
      };
const oneCustomChr customGrfx[] PROGMEM = {
  {0x1f, 0x1f, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe} ,  // ram at top
  {0x0, 0x0, 0x0, 0x0, 0x1f, 0x1f, 0xe, 0xe} ,  // ram at load
  {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x1f} ,  // ram at bottom
  {0x3, 0x4, 0x8, 0x8, 0x8, 0x5, 0x3, 0x7} ,    // arrow CCW
  {0x18, 0x4, 0x2, 0x2, 0x2, 0x14, 0x18, 0x1c}, // arrow CW
  {0x15, 0x0, 0xe, 0x11, 0x1f, 0x11, 0x0, 0x15},   // custom chr 'A'
  {0x15, 0x0, 0x11, 0x1b, 0x15, 0x11, 0x0, 0x15}      // custom chr 'M'
};
const byte customchr_qty = sizeof (customGrfx) / sizeof (customGrfx[0]);  // establish the number of custom characters

id have to convert my tables to hex, but lemme go see ill try anything at this point

No dice, arduino IDE has really poor port manipulation documentatrion

what i surmise is happening is it is trying to write 16 bits to an 8 bit register

when i use the constant int method i can specify B11111111. and when i do it this way it works putting just the numbers 11111111 does not …

of to beat goole again …

i think its the ide that has doomed me…

https://www.arduino.cc/en/Reference/PortManipulation

information shows no hope of assigning a decimal value to a port. which is plain F@#$%^& stupid. they use the B11111111 qualifier in the information… Microchip now owns bothe ATMega and PIC microcontrolelrs and you seriously cant be telling me that MPASM is more robust than Arduino… that would be SAD.

i have tried to change the type to uint8_t Also no dice.

the more i mess with this the more it is frustrating…

so far the only thing i have found that might work Uses String…

http://luckylarry.co.uk/programming-tutorials/arduino-programming/arduino-convert-decimal-to-binary/

ALL I WANNA DO IS PUT A BLEEPING DECIMAL ON THE BLEEPING PORTL

I don't think conversion to hex format will change anything, it's just a different way of looking at bits. Do note however, the placement of PROGMEM in your code vs. in what I show. I'm not knowledgeable enough to provide instruction or explain it, I just know it works for me.

dougp: i agree, in the arduino itself is just 0 and 1 any way its just a name (hex, bin etc) until you dtart manipulating entire ports then the B10101010 for mat is actually representing in my case the value of the pin... the binary.h in arduino has some clues i would suppose but i just cant decipher how to make it work.

i guess the most direct version of my question is >>> how do you store B10101010 values in PROGMEM...

how do you store B10101010 values in PROGMEM...

It seems quite easy

const byte theBytes[] PROGMEM = {B10101010, B01010101};

void setup()
{
  Serial.begin(115200);
  Serial.println(theBytes[0], BIN);
  Serial.println(theBytes[1], BIN);
}

void loop()
{
}

Note that it would be more mainstream to use

const byte theBytes[256] PROGMEM = {0b10101010, 0b01010101};

Can you be clearer about the problems that you had ?

ALL I WANNA DO IS PUT A BLEEPING DECIMAL ON THE BLEEPING PORTL

PORTB = 160;aka

PORTB =
0b10101010;

UKHeliBob:
It seems quite easy

const byte theBytes[] PROGMEM = {B10101010, B01010101};

void setup()
{
  Serial.begin(115200);
  Serial.println(theBytes[0], BIN);
  Serial.println(theBytes[1], BIN);
}

void loop()
{
}




Note that it would be more mainstream to use


const byte theBytes[256] PROGMEM = {0b10101010, 0b01010101};




Can you be clearer about the problems that you had ?

your very right it would seem quite easy indeed…

YouTube
as you can see in the video above. it is quite not.
ive attached the code i ran in the video and i fixed the glitch in the part of the video that worked and then messed up…

ps… what you get in the terminal and what you get in real life are often two very different exercises , thats why its called a debugging port :), on another note the table i use for the characters was actually generated and processed on an arduino, i had to invert rotate and bit swap all of the characters, that font is just all of the characters from the matrix font generator online crushed into 1 table sorted so that their incidences line up with the ascii table, and then with the values inverted because i have Common Cathode setup, and my columns run up and down and rows left to right which apparently the generator creates them to be used with the MAX7219 which does it a bit differently…

SkyNetDuino_CharToProgMEM.ino (43.5 KB)

ALL I WANNA DO IS PUT A BLEEPING DECIMAL ON THE BLEEPING PORTL

That has nothing to do with PROGMEM. Nor anything to do with whether your compile-time constants are in binary or hex...

YouTube
ive attached the code i ran in the video

There's no PROGMEM in the code you posted. However, from the video, it seems that you expect that using PROGMEM in the variable definition is all you need to do to move data from RAM to Flash. That is NOT the case on the AVR CPUs - you have to add pgm_read_byte() around your accesses, probably about like this:

        BufferM[i][j] = pgm_read_byte(&BitMask[Message[i]][j]);

See the pgmspace tutorials for more info...

(Interestingly, you wouldn't need to do that on an ARM. Search "Harvard architecture" if you want to start understanding why...)

you have to add pgm_read_byte() around your accesses,

So why does this work on a Uno ?

const byte theBytes[] PROGMEM = {123, 101};

void setup()
{
  Serial.begin(115200);
  Serial.println(theBytes[0]);
  Serial.println(theBytes[1]);
}

void loop()
{
}

So why does this work

Compiler optimization. theBytes[0] and theBytes[1] are known by the compiler to be constants, so you get:

Serial.println(123);
Serial.println(1);

theBytes probably isn't in the executable at all.

Yeah, it's somewhat annoying that the failure of that stage of optimization to understand PROGMEM results in such dramatically different behavior...

UKHeliBob:
So why does this work on a Uno ?

Make theBytes volatile and it will fail as expected.
(Yes, const volatile is a perfectly cromulent combination.)