我想让我的SAMD21芯片成为SPI奴隶。
我有下列图钉:
这些引脚大多属于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 (导航)板布局来编程芯片。
根据文件所述的图钉:
MISO 12 SERCOM4 2/
TC5 0/WO4 TC5 0/WO5 TC5 0/WO5
发布于 2022-11-15 20:11:00
谢谢你的问题。我刚看到你的帖子。我是你使用的存储库的作者。我将在此回复,供其他读者参考。
您的代码包含了一些问题。
为了更容易地使用不同的引脚,我发布了库的0.2.0版本。这将允许您使用任何SERCOM (SERCOM0到SERCOM5),并选择可用于该SERCOM的任何引脚。
请参阅存储库https://github.com/lenvm/SercomSPISlave上SercomSPISlave.h和https://github.com/lenvm/SercomSPISlave中的自述文件和代码注释,以进一步参考。
https://stackoverflow.com/questions/64158023
复制相似问题