12/13/2023 0 Comments Use sercom spi arduino zeroPA21 Pin = 21 // peripherals: TCC0 channel 3 PA20 Pin = 20 // peripherals: TCC0 channel 2 PA19 Pin = 19 // peripherals: TCC0 channel 3 PA18 Pin = 18 // peripherals: TCC0 channel 2 PA17 Pin = 17 // peripherals: TCC2 channel 1, TCC0 channel 3 PA16 Pin = 16 // peripherals: TCC2 channel 0, TCC0 channel 2 PA15 Pin = 15 // peripherals: TCC0 channel 1 PA14 Pin = 14 // peripherals: TCC0 channel 0 PA13 Pin = 13 // peripherals: TCC2 channel 1, TCC0 channel 3 PA12 Pin = 12 // peripherals: TCC2 channel 0, TCC0 channel 2 PA11 Pin = 11 // peripherals: TCC1 channel 1, TCC0 channel 3 PA10 Pin = 10 // peripherals: TCC1 channel 0, TCC0 channel 2 PA09 Pin = 9 // peripherals: TCC0 channel 1, TCC1 channel 3 PA08 Pin = 8 // peripherals: TCC0 channel 0, TCC1 channel 2 PA07 Pin = 7 // peripherals: TCC1 channel 1 PA06 Pin = 6 // peripherals: TCC1 channel 0 PA05 Pin = 5 // peripherals: TCC0 channel 1 PA02 Pin = 2 PA03 Pin = 3 PA04 Pin = 4 // peripherals: TCC0 channel 0 PA01 Pin = 1 // peripherals: TCC2 channel 1 SERCOM1->00 Pin = 0 // peripherals: TCC2 channel 0 On the following lines of code in SPI init function:ĪttachInterrupt(10, SERCOM1_Handler, FALLING) I am trying to use Tom_the_banana's SPI Slave code on an Adafruit Feather M0 with the 1.6.7 IDE and getting multiple identical compile errors -Įrror: request for member 'DIR' in 'PORTA', which is of non-class type '_EPortType' Serial.print("CTRLA: ") Serial.println(SERCOM1->) If(interrupts & ( = 1 //clear receive complete interrupt SERCOM1-> = 1 //clear receive complete interrupt Serial.print("DATA: ") Serial.println(data) If(interrupts & ( = 1 //clear slave select interrupt Uint8_t interrupts = SERCOM1-> //Read SPI interrupt register Interrupt Service Routine: void SERCOM1_Handler() You can use it for the Arduino Zero/Zero Pro to use Pin 10,11,12,13 (SS, MOSI, MISO, SCK)as SPI in slave mode. Here is my working example code with interrupt handler. I found the issue right away the problem was in the pinmux section, i didnt initialise MISO and SCK correctly. Okay just by posting this my brain went out of filtering my code mode, to look at your code correctly mode While(SERCOM1->) //wait until receiver is enabled SERCOM1-> = 0x1 //Enable Receiver, this is done here due to errate issue SERCOM1-> = 0x1 //Data Register Empty interrupt SERCOM1-> = 0x1 //Receive complete interrupt SERCOM1-> = 0x1 //Enable Slave Select low interrupt SERCOM1-> = 0x1 //Enable Preload Data Register SERCOM1-> = 0x1 //Slave Selecte Detection Enabled SERCOM1-> = 1 //wake on receiver complete SERCOM1-> = 0x1 //Buffer Overflow notification SERCOM1-> = 0x2 //DATA PAD3 MISO is used as output SERCOM1-> = 0 //DATA PAD0 MOSI is used as input (slave mode) SERCOM1-> = 0 //data sampled on leading sck edge and changed on a trailing sck edge SERCOM1-> = 0 //SCK is low when idle, leading edge is rising edge While(GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) //Wait for synchronisation GCLK_CLKCTRL_CLKEN // Enable Generic Clock Generator GCLK_CLKCTRL_GEN_GCLK0 | // Generic Clock Generator 0 is the source GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID(GCM_SERCOM1_CORE) | //Generic Clock 0 = 0x2 //SERCOM 1 is selected for peripherial use of this pad = 0x1 //Enable Peripheral Multiplexing for SERCOM1 SPI PA18 Arduino PIN10 |= PORT_PA19 //Set PA19 as output (MISO) &= ~PORT_PA16 //Set PA16 as input (MOSI) Here is my initialisation code for the spi module: void spiSlave_init() reading the datasheet multiple times for any hints. reading the configured registers to check if the initialisation where done correctly
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |