I don’t have a QWIIC micro - SAM21 DB, but the definitions in variant.h are not a pad or a pin. They are an offset to g_APinDescription, which is defined in variant.cpp in the same folder.
Be aware an index starts counting at 0 (zero). Also looked at the schematics.
offset(.h) port (.cpp) board-pin (schema)
MISO -> 14U -> PA05 connected to D3 (as can be seen on the backside of the board as well)
MOSI -> 15U -> PA06 connected to D2 (as can be seen on the backside of the board as well)
SCK -> 11U -> PA07 connected to D4 (as can be seen on the backside of the board as well)
SS -> 7u -> PA04 connected to D7
It is using Sercom0 for SPI. Looking at the datasheet, the Sercom0 pads can be multiplexed to the PA-portnumbers referenced above for the SAM21D.
For TX it is using Sercom0 - pad 2, which is multiplexed to PA06 and thus MOSI (Master OUT) or with the new name COPI (Controller Out, Peripheral In)
For RX it is using Sercom0 - pad 3, which is multiplexed to PA05 and thus MISO (Master IN) or with the new name CIPO (Controller In, Peripheral Out)
So look at the back of the board, do NOT use D5. ( I could not the D5 reference you mentioned) Also, use SPI ( not SPI1). Although the SAM21D can handle 4 wire SPI, the driver is expecting 3-wire with the SS (Chipselect) handled within the sketch (as can be seen within the examples)
the explanation with the variant.cpp makes absolutely sense. Yes, I used SPI and not SPI1. But I still don’t get, how sercom0 can be muxed to those pads?
My problem is, that there is no communication, and I also can’t measure any signals on that port (SCL / D4). I should be able to measure a clock signal there, right?
The pads from the SAM21D can be connected to different pins that are printed on the board. Each board can be (often is) different. In case of your first reference, the pins that are called out are those for Redboard-turbo. See the board picture above on the same page but also look at the graphical datasheet for that board https://github.com/sparkfun/RedBoard_Tu … oDev_1.pdf
I used an USB oscilloscope but can’t find any signal on SCK (D4)
Meanwhile I manually wired the pins (MOSI, MISO and SCK) of my PCB to the SPI SMD pads on the backside of the SAMD-Board and changed the code from SPI to SPI1 and that actually works.
But it’s not really a solution, as I designed my PCB already to fit D2 to D4 and I don’t like to reproduce it again.
Do you have any idea why SPI with pins D2 to D4 is not working for me?
Good to know it works with SPI1 with the same program.
Looks to me that your SAMD has a broken SERCOM0. I tried to see whether you could use one of the other SERCOMs, but the others depend on PA11 which is not connected to this board.
As it looks like an interesting board for me to explore further, I have ordered one which I should get tomorrow and then get try as well.
I have just tested a BME280 in SPI mode on the Qwicc micro. After connecting the wires from the BME280 to D2, D3, D4 and D5 according to the graphical interface and uploading the BME280 sketch it all worked as expected. I am afraid it looks like you have an issue with SERCOM0 on your board.