0

Feather M4's SCK, MOSI, MISO as GPIO
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather M4's SCK, MOSI, MISO as GPIO

by lawrenceyy on Wed Apr 24, 2019 12:41 pm

I am working on a small project where 5 fans turn on when their corresponding sonar sensor is tripped. Each fan takes one pin to control and the sensors take two. I got 3 of the fans and 3 of the sensor to work by using a mix of digital pins and analogue pins. For the last 2 fans, I am trying to use pin A3, A4, A5, SCK, MOSI and MISO as GPIO. However I am getting a runtime error: EXTINT channel already in use. I am under the impression that SCK, MOSI and MISO are usable as GPIO (https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51/pinouts). I do have a LED featherwing stacked on my M4, but that should be controlled over I2C, whose pins I am not touching.

Here is the setup portion of the code that is giving me the error:

Code: Select all | TOGGLE FULL SIZE
import time
import board
import digitalio
import busio
import adafruit_ssd1306
import adafruit_hcsr04

#setup
i2c = busio.I2C(board.SCL, board.SDA)
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
sonar=[]
sonar.append(adafruit_hcsr04.HCSR04(trigger_pin=board.A4, echo_pin=board.A3))
sonar.append(adafruit_hcsr04.HCSR04(trigger_pin=board.SCK, echo_pin=board.A5))
sonar.append(adafruit_hcsr04.HCSR04(trigger_pin=board.D11, echo_pin=board.D12))
sonar.append(adafruit_hcsr04.HCSR04(trigger_pin=board.D9, echo_pin=board.D10))
sonar.append(adafruit_hcsr04.HCSR04(trigger_pin=board.D5, echo_pin=board.D6))
fan=[]
fan.append(digitalio.DigitalInOut(board.MOSI))
fan.append(digitalio.DigitalInOut(board.MISO))
fan.append(digitalio.DigitalInOut(board.A0))
fan.append(digitalio.DigitalInOut(board.A1))
fan.append(digitalio.DigitalInOut(board.A2))
for i in range(len(fan)):
    fan[i].direction=digitalio.Direction.OUTPUT


My hardware questions were in this other post: https://forums.adafruit.com/viewtopic.php?f=8&t=150741

Thanks.

lawrenceyy
 
Posts: 77
Joined: Thu May 07, 2015 12:32 pm

Re: Feather M4's SCK, MOSI, MISO as GPIO

by tannewt2 on Wed Apr 24, 2019 12:56 pm

Hi lawrenceyy,
All pins are available as GPIO but the HCSR04 driver uses the external interrupt controller under the hood for the echo pin. This functionality is muxed so you can get pin conflicts.

I'd recommend consulting the data sheet for the exti mappings and making sure that all of the echo pins are on different lines.
~Scott

tannewt2
 
Posts: 1294
Joined: Thu Oct 06, 2016 8:48 pm

Re: Feather M4's SCK, MOSI, MISO as GPIO

by lawrenceyy on Wed Apr 24, 2019 6:30 pm

Thanks for the response.

I found the data sheet, but cannot make sense of the charts. Not even really sure what I am looking for. I'll shuffle around my pins and see if I can get every echo on different lines.

lawrenceyy
 
Posts: 77
Joined: Thu May 07, 2015 12:32 pm

Re: Feather M4's SCK, MOSI, MISO as GPIO

by lawrenceyy on Thu Apr 25, 2019 1:09 pm

I shuffled my wires around and got it to work. D6 was the one giving me problems. When it was three sensors, I only used pins on the north side of the board. But when I added that last two sensors, I had to utilize pins on the south side. D6 must to connected to something on the other side. Can we can the exti map added to https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51/pinouts for future reference?

Thanks.

lawrenceyy
 
Posts: 77
Joined: Thu May 07, 2015 12:32 pm

Please be positive and constructive with your questions and comments.