Go Down

Topic: Read and write to SD Card when PWM set to 62500 (Read 80 times) previous topic - next topic

azrulsaleh

Hi all. I can't seem to read or write to sd card when PWM is set to 62500. The txt file gets written every time no problem but the content will either be empty or filled with gibberish. For confirmation, I can read and write if the timer is unchanged no problem. What can I do to get it to work at this higher timer setting?

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
   TCCR0B = TCCR0B & 0b11111000 | 0x01;

   Serial.begin(9600);
   while (!Serial) {
      ;
   }

   myFile = SD.open("test.txt", FILE_WRITE);
   myFile.println("testing 1, 2, 3.");
   myFile.close();
}

void loop() {
   ;
}

azrulsaleh

Commenting out TCCR0B = TCCR0B & 0b11111000 | 0x01; allows the sd card to work but it really needs to be there for this project. Can anyone help?

Go Up