Hi everyone,.
Please help me place the ads of the matrix byteMatrix and the values the matrix byteMatrix in additional memory 8MB PSRAM chip. Memory PSRAM is already on Teensy 4.1 and tested. When compiling, only load RAM1. Below is my code.
Thanks in advance for the community's support.
Please help me place the ads of the matrix byteMatrix and the values the matrix byteMatrix in additional memory 8MB PSRAM chip. Memory PSRAM is already on Teensy 4.1 and tested. When compiling, only load RAM1. Below is my code.
Thanks in advance for the community's support.
Code:
#include <SD.h>
#include <SPI.h>
#include <malloc.h>
#include "LittleFS.h"
extern "C" uint8_t external_psram_size;
const int chipSelect = BUILTIN_SDCARD; //Teensy 4.1
const int rows = 1000; // 200 max
const long cols = 36000; // 17000 max
File file;
byte byteMatrix[rows][(cols + 7) / 8]; // объявление байтовой матрицы
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
file = SD.open("mat36000.txt", FILE_READ); // m80-200
if (!file) {
Serial.println("No open file.");
return;
}
// read data from file and convert to byte array
for (int i = 0; i < rows; i++) {
for (long j = 0; j < cols; j++) {
int value = file.parseInt();
if (value == 1) {
byteMatrix[i][j / 8] |= (1 << (7 - (j % 8)));
}
}
}
file.close();
// displaying element values
for (int i = 0; i < rows; i++) {
for (long j = 0; j < cols; j++) {
byte bitValue = (byteMatrix[i][j / 8] >> (7 - j % 8)) & 1;
Serial.print(bitValue);
Serial.print(" ");
}
Serial.println();
}
}
void loop() {
// code
}