Storing unsigned int (2 bytes) in Flash Memory on a Teensy 3.6

Status
Not open for further replies.

hbtousa

Active member
I stored +34000 lines of 16-bit data on flash memory. The code works good; but, I have two issues that I don't understand why they are happening. After running the code, I am able to see all data on the serial port without a problem. The issue arises after I close the serial port and I reopen it back on again. No data shows at all. Is that a something related to my code, or teensy.? The second issue happens while loading/compiling. Some messaggges appear at the bottom of the screen but I the end code compiles and uploads without problem. The messages are : "

eensyMemoryBench:34145: warning: narrowing conversion of '4406636708352ll' from 'long long int' to 'uint16_t {aka short unsigned int}' inside { }
TeensyMemoryBench:34145: warning: large integer implicitly truncated to unsigned type
TeensyMemoryBench:34145: warning: narrowing conversion of '4406636708352ll' from 'long long int' to 'uint16_t {aka short unsigned int}' inside { }
TeensyMemoryBench:34145: warning: large integer implicitly truncated to unsigned type
TeensyMemoryBench:34145: warning: narrowing conversion of '4406636708352ll' from 'long long int' to 'uint16_t {aka short unsigned int}' inside { }
TeensyMemoryBench:34145: warning: large integer implicitly truncated to unsigned type
TeensyMemoryBench:34145: warning: narrowing conversion of '1224736841' from 'int' to 'uint16_t {aka short unsigned int}' inside { }
TeensyMemoryBench:34145: warning: large integer implicitly truncated to unsigned type
TeensyMemoryBench:34145: warning: narrowing conversion of '1224736841' from 'int' to 'uint16_t {aka short unsigned int}' inside { }
TeensyMemoryBench:34145: warning: large integer implicitly truncated to unsigned type
TeensyMemoryBench:34145: warning: narrowing conversion of '1224736841' from 'int' to 'uint16_t {aka short unsigned int}' inside { }

Are those messages because the data is bad somehow? or is this a normal step while processing the data.

Finally, another question that I need to get help with is how many more lines of data, same format "111111111111111", can I add to the teensy 3.6 flash memory?
I am pretty fairly new to teensy.

Thanks very much

Code:
const uint16_t NUMBER_OF_ELEMENTS = 34140;
const uint16_t descriptions[NUMBER_OF_ELEMENTS]  =
{
// All 34000 Lines of data...
0000011100000111,
0000011100000111,
0000011100000111,
0000011100000111,
0000011100000111,
0000010100000101,
0000010100000101,
0000010100000101,
0000010100000101,
1110000011100000,
1110000011100000,
1110000011100000,
1110000011100000,
1110000011100000,
1110000011100000,
1110000011100000,
1111000011110000,
1111000011110000,
1111000011110000,
1111000011110000,
1111000011110000,
1111000011110000,
1111000111110001,
1111000111110001,
1111000111110001,
1111000111110001,
1111001111110011,
1111001111110011,
1111001111110011,
1111001111110011,
1111001111110011,

};

int bitNumber;
int totalBits;
String alphaChannels ;
unsigned int displayByte;
void setup ()
{
  Serial.begin (115200);
  Serial.println ();
  while (!Serial && millis() < 6000) ;
 

  for (unsigned k = 0; k < 34140; k++)
  {
    displayByte = descriptions[k];
    alphaChannels =  String(displayByte, BIN);
    totalBits = alphaChannels.length();
    Serial.print(k);
    Serial.print("-) ");
    Serial.print(totalBits);
    Serial.print("* ");
    Serial.print(alphaChannels);
    Serial.print("* ");
    Serial.print(displayByte, DEC);
    Serial.print("* ");    
    Serial.println();
    delay(5);
  }
 


}  


void loop () {}
 
I assume you want the data in descriptions array to be in binary format, in that case they must be prefixed with 0b like
Code:
0b0000011100000111,

Your program only outputs the data once in the setup and the serial monitor is cleared when it is closed. So the output is lost when you close the serial monitor. If you want to display it again then that must somehow be done in loop() function. You could send a command character (like 'p' as in print) to make your code print again using something like:

Code:
  if (Serial.available()) {
    char inchar = Serial.read();
    if (inchar == 'p') {
       /* Print your stuff here */
    }
  }
 
uint16_t can only store numbers in the range 0 to 65535. The compiler is warning you that it can't cram a number like 4406636708352ll into 16 bits. That number requires 43 bits which is why it has the 'll' on the end to indicate that it should be stored in a 64-bit integer.

Pete
 
yes. you are right I double the amount to 68280 and gave me error; I switched to
Code:
const uint16_t NUMBER_OF_ELEMENTS = 65500;
const uint16_t descriptions[NUMBER_OF_ELEMENTS]  =
{
0b0000000000000000,....


and everything worked perfect and it used only 13% of program space.

Sketch uses 145964 bytes (13%) of program storage space
 
Status
Not open for further replies.
Back
Top