avr_boot icon indicating copy to clipboard operation
avr_boot copied to clipboard

Changing CS to Pin 14

Open ratbertDS opened this issue 7 years ago • 4 comments

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!

ratbertDS avatar Aug 12 '18 15:08 ratbertDS

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?

per1234 avatar Aug 12 '18 16:08 per1234

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

ratbertDS avatar Aug 12 '18 16:08 ratbertDS

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

per1234 avatar Aug 12 '18 17:08 per1234

Wow! Thank you so much..

ratbertDS avatar Aug 12 '18 17:08 ratbertDS