问题描述
我正试图将SAMD21芯片设为SPI从设备。
我有以下针脚:
- PB10作为MOSI
- PB11作为SCK
- PA10为SS
- PA12作为MISO
这些引脚大多数属于SERCOM4
但是,当我按如下所示设置它们时,它们不能正常工作:
PORT->Group[PORTB].PINCFG[10].bit.PMUXEN = 0x1; //Enable Peripheral Multiplexing for SERCOM4 SPI PA12 Arduino PIN22
PORT->Group[PORTA].PMUX[6].bit.PMUXE = 0x3; //SERCOM 4 is selected for peripheral use of this pad (0x3 selects peripheral function D: SERCOM-ALT)
PORT->Group[PORTB].PINCFG[11].bit.PMUXEN = 0x1; //Enable Peripheral Multiplexing for SERCOM4 SPI PB09 Arduino PIN16
PORT->Group[PORTB].PMUX[4].bit.PMUXO = 0x3; //SERCOM 4 is selected for peripheral use of this pad (0x3 selects peripheral function D: SERCOM-ALT)
PORT->Group[PORTA].PINCFG[10].bit.PMUXEN = 0x1; //Enable Peripheral Multiplexing for SERCOM4 SPI PB10 Arduino PIN23
PORT->Group[PORTB].PMUX[5].bit.PMUXE = 0x3; //SERCOM 4 is selected for peripheral use of this pad (0x3 selects peripheral function D: SERCOM-ALT)
PORT->Group[PORTA].PINCFG[12].bit.PMUXEN = 0x1; //Enable Peripheral Multiplexing for SERCOM4 SPI PB11 Arduino PIN24
PORT->Group[PORTB].PMUX[5].bit.PMUXO = 0x3; //SERCOM 4 is selected for peripheral use of this pad (0x3 selects peripheral function D: SERCOM-ALT)
我使用的是 https://github.com/lenvm/SercomSPISlave
我使用arduino IDE和SAMD对芯片进行编程:M0或M0 Pro(原始)板布局。
根据文档说明的针脚:
- | 1 | 1
- | 22 | 1 | PA12 | MISO | EIC / EXTINT [12] SERCOM2 / PAD [0] * SERCOM4 / PAD [0] TCC2 / WO [0] TCC0 / WO [6]
- | 23 | 4 | PB10 | MOSI | EIC / EXTINT [10] * SERCOM4 / PAD [2] TC5 / WO [0] TCC0 / WO [4]
- | 24 | 3 | PB11 | SCK | EIC / EXTINT [11] * SERCOM4 / PAD [3] TC5 / WO [1] TCC0 / WO [5]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)