FatFs and two SPI slaves

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Everyone,

I've the following problem. I'm using FatFs library to write and read data from an SD card. Apart from the card I have another avr connected to the main microcontroller. Basically, I want to read data from the card and send it to the other uc via SPI too.

When I do this, SPI transmission to the other AVR works:

f_mount(0, &fatfs[0]);
Send_SPI_data_to_the_other_avr();
f_open(&file1, "file1.txt",  FA_WRITE | FA_OPEN_ALWAYS);

But when I do this:

f_mount(0, &fatfs[0]);
f_open(&file1, "file1.txt", FA_WRITE | FA_OPEN_ALWAYS);
Send_SPI_data_to_the_other_avr();

Data that the other avr gets is all 0xff. What does the function f_open do to SPI transmission? Does anyone have any idea?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Check to make sure that you have all your chip-selects turning on and off properly. Also that the change in speeds from init to run is done properly.

I have a FatFs and two SPI slaves with different SPI characteristics and it works OK. (And I also have level-translation from the 5V AVR app to the SD card.)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You were right. I didn't turn off the chip-select of the other avr when writing to the card, and so it got data it wasn't supposed to. Thanks a lot!