Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing CS to Pin 14 #28

Open
ratbertDS opened this issue Aug 12, 2018 · 4 comments
Open

Changing CS to Pin 14 #28

ratbertDS opened this issue Aug 12, 2018 · 4 comments

Comments

@ratbertDS
Copy link

Hi for my project I have the CS Line wired to Pin 14 for the SD Card. I'm a bit of a newbie here to changing bootloaders. Can some one give me a clue to exactly what needs changing to make this work. The CPU is a 328p 3,3v Device.
Thanks!

@per1234
Copy link
Contributor

per1234 commented Aug 12, 2018

By "Pin 14", do you mean the Arduino pin number (as you would use with digitalWrite(), etc.) or do you mean physical pin 14 on the ATmega328P chip?

If the latter, what is the IC package of your ATmega328P?

@ratbertDS
Copy link
Author

ratbertDS commented Aug 12, 2018

So I am using a 3,3v Pro Mini.
And I am connecting the SD Card as follows:
CS -> Arduino pin A0
MOSI -> Arduino D11
SCLK -> Arduino D13
MISO -> Arduino D12
Does that make any better sense? Sorry as I said newbie

@per1234
Copy link
Contributor

per1234 commented Aug 12, 2018

OK. That's the information I needed. avr_boot doesn't use Arduino pin numbers to define the CS pin. It uses the PORT/BIT number. So the first thing is to determine the pin mapping of Arduino pin 14 on the Pro Mini. From this handy chart:
68747470733a2f2f692e696d6775722e636f6d2f545a34476d79522e6a7067

we can see that Arduino pin 14 is PC0 (PORTC, BIT 0).

You can define the CS pin port and bit either by editing lines 9-11 of the Makefile or via the SD_CS_PORT, SD_CS_DDR, and SD_CS_BIT arguments to make. I prefer the latter. So the correct make command is this:

make MCU_TARGET=atmega328p BOOT_ADR=0x7000 F_CPU=8000000 SD_CS_PORT=PORTC SD_CS_DDR=DDRC SD_CS_BIT=0 USE_LED=0 USE_UART=0 ADDED_CFLAGS="-Wextra -Wno-strict-aliasing" TARGET=$(MCU_TARGET)_cs14_$(F_CPU)L

@ratbertDS
Copy link
Author

Wow! Thank you so much..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants