Indeed this is correct. The 1062 was changed to FAST GPIO mode and that invalidates access using GPIO1-4 and moves them to GPIO6-9 for access unless the FAST IO setting is undone.
The imxrt.h file contains function macro information for access to those pins as GPIO6,7,8,9
So how it is possible that I can still access GPIO1-4 with success and with no compilation errors?
Hello.
Because I needed to minimize bit manipulation for fast operation, pins I have selected as ADC inputs are from GPIO6 and GPIO7 groups. I'm using 2x14bit ADC now (so 28pins used).
Unfortunately now I need to use SPI interface also, and pins for SPI and SPI1 shown in teensy 4.1 pinout card have been already used as ADC inputs.
Am I now left with Software SPI, or can I still assign any pins for hardware SPI?
Are you using either the micro-SD card or the psram/flash memory pads underneath the Teensy 4.1?
If you aren't using the micro-SD card, you could use something like this to bring out the SD pins:
And the two sets of solder pads underneath the Teensy use FlexSPI. I don't know if that would work for your purposes.
I think SD card in teensy 4.1 is not SPI driven. Could you explain your ideas a little bit more?
In other words: what pins can be assigned to:
SPI.setMOSI(pin)
SPI.setMISO(pin)
SPI.setSCK(pin)
?
pinMode(19, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(40, INPUT_PULLUP);
pinMode(41, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(22, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(21, INPUT_PULLUP);
pinMode(38, INPUT_PULLUP);
pinMode(39, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(32, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(36, INPUT_PULLUP);
pinMode(37, INPUT_PULLUP);
pinMode(35, INPUT_PULLUP);
pinMode(34, INPUT_PULLUP);
I know that teensy 4.1 has alternate pins but I don't know which they are.
I'm currently using pins listed below for adc reading.
Are there any pins left that can be assigned so I have one working SPI interface?
#if defined(ARDUINO_TEENSY41)
const SPIClass::SPI_Hardware_t SPIClass::spiclass_lpspi4_hardware = {
CCM_CCGR1, CCM_CCGR1_LPSPI4(CCM_CCGR_ON),
DMAMUX_SOURCE_LPSPI4_TX, DMAMUX_SOURCE_LPSPI4_RX, _spi_dma_rxISR0,
12, 255, // MISO
3 | 0x10, 0,
0, 0,
IOMUXC_LPSPI4_SDI_SELECT_INPUT,
11, 255, // MOSI
3 | 0x10, 0,
0, 0,
IOMUXC_LPSPI4_SDO_SELECT_INPUT,
13, 255, // SCK
3 | 0x10, 0,
0, 0,
IOMUXC_LPSPI4_SCK_SELECT_INPUT,
10, 37, 36, // CS
3 | 0x10, 2 | 0x10, 2 | 0x10,
1, 2, 3,
0, 0, 0,
&IOMUXC_LPSPI4_PCS0_SELECT_INPUT, 0, 0
};
#else
#if defined(ARDUINO_TEENSY41)
const SPIClass::SPI_Hardware_t SPIClass::spiclass_lpspi3_hardware = {
CCM_CCGR1, CCM_CCGR1_LPSPI3(CCM_CCGR_ON),
DMAMUX_SOURCE_LPSPI3_TX, DMAMUX_SOURCE_LPSPI3_RX, _spi_dma_rxISR1,
1, 39,
7 | 0x10, 2 | 0x10,
0, 1,
IOMUXC_LPSPI3_SDI_SELECT_INPUT,
26, 255,
2 | 0x10, 0,
1, 0,
IOMUXC_LPSPI3_SDO_SELECT_INPUT,
27, 255,
2 | 0x10, 0,
1, 0,
IOMUXC_LPSPI3_SCK_SELECT_INPUT,
0, 38, 255,
7 | 0x10, 2 | 0x10, 0,
1, 1, 0,
0, 1, 0,
&IOMUXC_LPSPI3_PCS0_SELECT_INPUT, &IOMUXC_LPSPI3_PCS0_SELECT_INPUT, 0
};
Those pins are the same as the T4 pins that are on the outside of board... And almost identical to the pins on T3.6/T3.5 at those exact positions.
That is On/Off, Program, GND 3.3V and VBat... The difference to T3.6/3.5 is the ON/OFF pad replaced the Reset pad.
As mentioned there are very few alternate SPI pins. As also probably mentioned there are more than one SPI...
But to use them, you use the individual objects: SPI, SPI1, SPI2.
And in most cases like this, I end up looking at the source code... But then again I was involved in it.
Example the hardware description data for the SPI object:
Yes most of this looks random: but I see, thatCode:#if defined(ARDUINO_TEENSY41) const SPIClass::SPI_Hardware_t SPIClass::spiclass_lpspi4_hardware = { CCM_CCGR1, CCM_CCGR1_LPSPI4(CCM_CCGR_ON), DMAMUX_SOURCE_LPSPI4_TX, DMAMUX_SOURCE_LPSPI4_RX, _spi_dma_rxISR0, 12, 255, // MISO 3 | 0x10, 0, 0, 0, IOMUXC_LPSPI4_SDI_SELECT_INPUT, 11, 255, // MOSI 3 | 0x10, 0, 0, 0, IOMUXC_LPSPI4_SDO_SELECT_INPUT, 13, 255, // SCK 3 | 0x10, 0, 0, 0, IOMUXC_LPSPI4_SCK_SELECT_INPUT, 10, 37, 36, // CS 3 | 0x10, 2 | 0x10, 2 | 0x10, 1, 2, 3, 0, 0, 0, &IOMUXC_LPSPI4_PCS0_SELECT_INPUT, 0, 0 }; #else
The only MISO is 12, MOSI os 11 SCK is 13 and it has 3 chip select pins 10 37 36. Note these CS pins are very different that T3.x...
And likewise SPI1:
MISO(1, 39), MOSI(26), SCK(27), and two CS pins (0, 38).Code:#if defined(ARDUINO_TEENSY41) const SPIClass::SPI_Hardware_t SPIClass::spiclass_lpspi3_hardware = { CCM_CCGR1, CCM_CCGR1_LPSPI3(CCM_CCGR_ON), DMAMUX_SOURCE_LPSPI3_TX, DMAMUX_SOURCE_LPSPI3_RX, _spi_dma_rxISR1, 1, 39, 7 | 0x10, 2 | 0x10, 0, 1, IOMUXC_LPSPI3_SDI_SELECT_INPUT, 26, 255, 2 | 0x10, 0, 1, 0, IOMUXC_LPSPI3_SDO_SELECT_INPUT, 27, 255, 2 | 0x10, 0, 1, 0, IOMUXC_LPSPI3_SCK_SELECT_INPUT, 0, 38, 255, 7 | 0x10, 2 | 0x10, 0, 1, 1, 0, 0, 1, 0, &IOMUXC_LPSPI3_PCS0_SELECT_INPUT, &IOMUXC_LPSPI3_PCS0_SELECT_INPUT, 0 };
Edit: Should also mention SPI2 has MISO, MOSI, SCK pins on both the SDCard pins as well as the back memory pins.
Sorry I have not fully gone back through all of this thread to know what it is you need. There is also a possibility of additional logical SPI objects, using FlexIO. I have a working version, but as it does not build from the same base class, it is a little more difficult to substitute in as a replacement.
Since the Teensy is marketed as being an Arduino-type device, I was hoping to find some less overwhelming documentation for doing common tasks.
For an example, I saw a code fragment that used "GPIO9_DR_TOGGLE = X". That seems like it would be a rather handy command for some situations. But how do you use it? What exactly does it do? Where did that come from? How would I have been able to find out about it without seeing it in someone else's program? How do people know about these things? And I'm sure there are many more .