Go Down

Topic: Exceptional 1284p try SD <SOLVED> (Read 1 time) previous topic - next topic

Redfizh

Nov 22, 2019, 12:04 pm Last Edit: Nov 24, 2019, 10:36 am by Redfizh

EDIT:
SOLVED///
Upgrading whole project with MightyCore and it's nice setups solved all pin-issues. SD and SPI -libraries worked well with 4Gb microSD-card and adapter that had logic level shifter. The final nail in the coffin was setting the SS as output (just didn't remember). I used Bobuino-pins 10,11,12,13 for SPI. Adapter with resistors or that SD-card I used with it didn't work but who cares :D I'm happy
///SOLVED


I have been upgrading "Single Chip Basic Computer" from HackaDay.io over 4 years and this time I'm adding SD-card. Original one never got TVout and SD working at same time. I have external mcu for graphics over serial so that issue should be solved. This project is deeply based on those files from HackaDay so I'm using ArduinoIDE1.0.5 and USBasp. Bootloader is "Mighty 1284p 16Mhz"

I think my 1284p is exceptional, cause every pin I ever set to anything is wrong. Same files, same circuit, same hardware.. different pins. And it's always two less. I always managed to set these right until SD.
When I ask what pins are SS, MISO, MOSI, SCK I get: 10,11,12,13.
But when I set 10 high, instead PB2 is high. That's physically two pins away and so are next pin's too.

Card is 4Gb micro-SD formatted to Fat32 with program shared in these forums. I use micro SD-card adapter from ebay that has on-board logic level shifter and voltage regulator. I did check the voltage and after regulation it's 3.2v, regulated from 4.9v. I also did try other SD-adapter that had resistors instead level shifter.

In Sd2Pinmap.h I added 1284p next to 644
Combinations of pins I tested:
- CS pins 4,6,10,12
- I did try all these pins as output
- I also did try these pins high
- Sd2Pinmap.h I changed SPI-pins 4-7, 6-9, 10-13, 12-15
Some combinations give "initialization failed" and some just simply stop.
I did try to follow SD initialization process from script but could not manage to figure out what to change.
I use dupont-wires from adapter to same port I use with USBasp (have to reconnect after every upload)
and CS pin is directly to the pin. All leads are tested.
external eeprom did work over SPI.

I did google every topic about 1284p and SD. None of them had solution or was anything what I've already done.

Feel free to ask more information. Will do everything you recommend, daily! I appreciate your help.

If no solution (or I'm hopeless):
I really would like to have a real file-system so I'm ready to change a lot to make it work. I heard this Mighty 1284 is ancient and so is my IDE. What would you recommend?
If anyone has TinyBasic working on 1284p and SD at same time I'll be super interested.

Juraj

#1
Nov 22, 2019, 12:40 pm Last Edit: Nov 22, 2019, 12:47 pm by Juraj
can you post a photo of your 1284p dev board?

do you have a pin mapping between the MCU io pins and the pins of the board? if not, create one.

do you use the MightyCore? you can add your pin mapping if the existing mappings don't match your board

why do you use USBasp if you have a bootloader?

srnet

For my 1284P based projects, I use Mighty Core, with the Bobuino pinout selected, and serail bootloader.

Never had a problem with pins not being the number they are supposed to be or getting the SD working.
http://www.50dollarsat.info/
http://www.loratracker.uk/

Juraj

For my 1284P based projects, I use Mighty Core, with the Bobuino pinout selected, and serail bootloader.

Never had a problem with pins not being the number they are supposed to be or getting the SD working.
and what dev board do you use?

srnet

and what dev board do you use?
I design and build my own.

One is a plug in replacement for a Pro Mini ...........................
http://www.50dollarsat.info/
http://www.loratracker.uk/

Juraj

I design and build my own.

One is a plug in replacement for a Pro Mini ...........................
then the mapping is your choice and you followed the Bobuino pinout, then no wonder that it works

Redfizh

#6
Nov 22, 2019, 07:25 pm Last Edit: Nov 22, 2019, 09:52 pm by Redfizh
can you post a photo of your 1284p dev board?




This is small part of the whole system. Yes it's ugly as it's made from corpses of previous boards. Also those SD-adapters and cards I have. 16Mb card is Fat16

do you have a pin mapping between the MCU io pins and the pins of the board? if not, create one.
do you use the MightyCore? you can add your pin mapping if the existing mappings don't match your board
I would love to learn how to map those. I'll look for this. I have that old Mighty. This MightyCore seem's newer. Should I upgrade if it's even possible?

why do you use USBasp if you have a bootloader?
USBasp was cheap and used when I started making this. As it was used in HackaDay -instructions, I assumed that it's used for uploading only. I dont know why I had to install bootloader in the first place but that's what I was told :D Right now USBasp is the only device between PC and MCU. Can it cause any harm if I have bootloader and still use USBasp?

EDIT: From MightyCores readme: "Keep your programmer connected, and hold down the shift button while clicking Upload. This will erase the bootloader and upload your code using the programmer tool." - I'm beginning to understand

Redfizh

For my 1284P based projects, I use Mighty Core, with the Bobuino pinout selected, and serail bootloader.
Never had a problem with pins not being the number they are supposed to be or getting the SD working.
I found out from files that I have Bobuino-like pinmap (10,11,12,13). It's just that it does not quite match what it should be. Sanguino-like pinmap suggested by Sd2pinmap.h was 4,5,6,7 for SPI -settings. I think I'll try MightyCore. I bet it will have some issues with current script but it's meant to evolve anyway.

Juraj

the pictures are not shown
if you do an ICSP upload the bootloader is deleted.
you can test pins with a LED
the MightyCore requires IDE 1.6.4

if you mapped the pins you will know which pins are the SPI pins PB5, PB6, PB7, but it should be the same pins as for ICSP + one pin for CS. And the SS pin PB4 must be output (so ideal for CS)

Redfizh

#9
Nov 22, 2019, 10:18 pm Last Edit: Nov 23, 2019, 05:34 am by Redfizh
Images should work now, sorry.
So in other words that Mighty1284 bootloader is long gone and I didn't have a clue :D
I usually write small blink-code and try with voltage meter. That's how I know how messed my pins are.
It's odd how spiEEPROM work's well. It has no pin-setups as it uses those main mapped pins.
I did try CS,MISO,MOSI,SCK definitions directly to Sd2Pinmap.h but it didn't like it.

I'll look for newest Arduino IDE tomorrow and see how outdated my code is.

Juraj

#10
Nov 23, 2019, 07:56 am Last Edit: Nov 23, 2019, 08:24 am by Juraj
Images should work now, sorry.
So in other words that Mighty1284 bootloader is long gone and I didn't have a clue :D
I usually write small blink-code and try with voltage meter. That's how I know how messed my pins are.
It's odd how spiEEPROM work's well. It has no pin-setups as it uses those main mapped pins.
I did try CS,MISO,MOSI,SCK definitions directly to Sd2Pinmap.h but it didn't like it.

I'll look for newest Arduino IDE tomorrow and see how outdated my code is.
I see the picture now. It would be enough to mention that it is a not a dev board but your build on a perfboard, so no traces to board's pins. If I had such a build, I would make pins_arduino.h with a MCU physical pin mapping to port/bit.

the SD library should use the SPI library, which should use pins defined in board variant .h file.
I have a 1284p dev board which is not defined in AVR or MightyCore boards package. I use it with Arduino AVR package, but I have it defined in my hardware folder in pins_arduino.h

Redfizh

#11
Nov 23, 2019, 12:20 pm Last Edit: Nov 23, 2019, 01:50 pm by Redfizh
I installed the newest IDE, MightyCore and tested CardInfo. I can't read serial as I broke power-plug from the system so I use blink-method to tell if it initializes or not. I get my power from USB now. I separated rest of the system so there is only 1284p and SD -boards. Also my soldering iron is not heating up and Zadig messed my keyboard drivers. I had really bad morning.

Good news is that MightyCore with Bobuino-pinmapping is correct. When I set pin 1 high, it does so.

I did try and if pin 1 gets low it fails and when blinking it works.
Sadly it didn't blink at all and as I set it high before initialization. Seem's that it stop's at SD.Begin. I'll list main causes I find (google). Half way there already :D What next?

EDIT: I used half speed when testing.

Redfizh

Solved, description in first message. I thank for your support. MightyCore is nice. Next I buy new soldering iron and try to feed old code for the new IDE as it really hate's PROGMEM parts of the code.

Go Up