Petit FatFS implementation

Go To Last Post
57 posts / 0 new

Pages

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

I guess I just need to ditch the 8515 and get something with debugging features.  The 162 appears to be pin compatible with 8515 and has JTAG so that might be something to try or I might just go back to the drawing board.

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

Rooney wrote:

That worked, sort of.  It didn't work at first but then I found disconnecting the AVR Dragon from SPI and power cycling (resetting doesn't work) the circuit allows the card to initialize and open a file... so maybe that was the issue all along, or maybe not.  Regardless, now it reads data but I think I'm getting unreliable results.  I will have to set up a better way to indicate results for debugging (and disconnecting SPI is a real nuisance!).  I'm certainly happy to see some progress though.

 

I'm glad you now can use the pfsample program.  It is rather nice to gain some experience with PetitFF.  I use an USBASP as a programmer and have never been able to leave it connected when I use the same pins for other SPI devices. I have not read the Atmel AVR042 application note (attached) thoroughly but it may show one possible solution.

 

Since you are using a software implementation of SPI, why not just move all the SPI outputs from PORTB to PORTA.  Then you should be able to leave the SPI leads connected while programming and the Dragon connected when running.  I did that with the ATtiny861's USI hardware and its alternate port (USIPP) capability.  All you have to do is change the #defines at the beginning of susi.S and move your wires over to PA0 through PA3.

; port and pin setup
#define DDR_CS		_SFR_IO_ADDR(DDRA), PA3		// Set CS pin Direction
#define	PORT_CS		_SFR_IO_ADDR(PORTA), PA3	// Set CS pin State
#define DDR_CK		_SFR_IO_ADDR(DDRA), PA2		// Set CLK pin Direction
#define	PORT_CK		_SFR_IO_ADDR(PORTA), PA2	// Set CLK pin State
#define DDR_DO		_SFR_IO_ADDR(DDRA), PA1		// Set DO pin Direction
#define	PORT_DO		_SFR_IO_ADDR(PORTA), PA1	// Set DO pin State
#define DDR_DI		_SFR_IO_ADDR(DDRA), PA0		// Set DI pin Direction
#define	PORT_DI		_SFR_IO_ADDR(PORTA), PA0	// Set DI pin State
#define	PORT_DI		_SFR_IO_ADDR(PORTA), PA0	// Apply pull-up resistors
#define PIN_DI		_SFR_IO_ADDR(PINA), PA0		// get DI input state

Have to move to another computer to attach the file.

Alan

Attachment(s): 

Last Edited: Mon. Apr 22, 2019 - 12:09 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rooney wrote:
I found disconnecting the AVR Dragon from SPI

When you have SPI devices, you need to use a weak pull-down/pull-up to keep it de-selected during other activity on the SPI bus.  I've lost track but this includes ISP activity when the AVR is in reset.

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

allano wrote:
Since you are using a software implementation of SPI, why not just move all the SPI outputs from PORTB to PORTA.  Then you should be able to leave the SPI leads connected while programming and the Dragon connected when running.

 

All my IO lines are serving other purposes but for reasons of troubleshooting the SD-Card I could remove those connections to do as you suggest.

 

theusch wrote:
When you have SPI devices, you need to use a weak pull-down/pull-up to keep it de-selected during other activity on the SPI bus.  I've lost track but this includes ISP activity when the AVR is in reset.

 

Okay, so I have 1k resistors on the SD-Card adapter's MOSI, MISO, and CLK lines as per this thread which corrected my issue of SPI not working after adding the card reader.  I also at one point had a 10k pullup on the card adapter's MISO line as per this post in this thread.  I'll investigate what you mentioned, thank you.

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

Did you get the drift?-- the select line; not clock or data in or data out...

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

Yes, I understand, thank you for making sure.

Pages