Go Down

Topic: ICSP arduino zero (Read 535 times) previous topic - next topic

Juraj

yes I'm using a shield, which a collegue has made and which works for the uno.

Since the pins MOSI, MISK and SCK should the only ones which get changed, it should work.

I know that the webpage talks about Teensy, but the same works for the UNO and should also work for the Zero with a different SPI.h
does the shield connect SPI on the ICSP header or on pins 11,12,13?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

gab27


gab27

My SPI.h has a include Arduino.h, and this file has a variant.h

In the variant.h there are these lines of code:

Code: [Select]
/*
 * SPI Interfaces
 */
#define SPI_INTERFACES_COUNT 1

#define PIN_SPI_MISO         (22u)
#define PIN_SPI_MOSI         (23u)
#define PIN_SPI_SCK          (24u)
#define PERIPH_SPI           sercom4
#define PAD_SPI_TX           SPI_PAD_2_SCK_3
#define PAD_SPI_RX           SERCOM_RX_PAD_0

static const uint8_t SS   = PIN_A2 ; // SERCOM4 last PAD is present on A2 but HW SS isn't used. Set here only for reference.
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK  = PIN_SPI_SCK ;



and in the variant.cpp these:

Code: [Select]
// 22..24 - SPI pins (ICSP:MISO,SCK,MOSI)
  // ----------------------
  // pins should be the same as in variant.h
  { PORTA, 12, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_12 }, // MISO: SERCOM4/PAD[0]
  { PORTB, 10, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, // MOSI: SERCOM4/PAD[2]
  { PORTB, 11, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // SCK: SERCOM4/PAD[3]


There I have also tried it 22,23,24 than 12,10,11.


Juraj

22, 23, 24 are pin numbers for the pins on the ISCP headers. the 12, 10, 11 are bit positions in PORT registers
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

gab27


Go Up