Teensy 4.1 Using DMA to generate control signals and synchronise buffer reading

Status
Not open for further replies.
I'm trying to use a Teensy4.1 to control and read an image from a STAR 1000 radiation hardened image sensor.

Reading from this sensor requires setting input pins correctly at a frequency between 10-20MHz, and simultaneously reading a 10 bit bus at precise times of this control sequence.

To generate the control signals I was thinking of using the AD_B1_00 - AD_B1_15 GPIO pins driven using DMA so the pattern of control signals can be stored in RAM. I have not managed to find a single GPIO port left over at this point which contains 10 pins. However B0_xx and B1_xx combined could be used if it is possible to use DMA to read both these ports at the same time.

I was also considering the option of ditching DMA and writing a single loop with NOP's to control timing, which would write to AD_B1_xx and then read from B0_xx and B1_xx. I'm concerned that cache hit/misses would wreak the timing if this read from a large block of memory.

Sorry for the rambling ideas, I'm trying to work out if my project is possible. Thanks.
 
I have no problems with reading a clock pin (polling loop, not DMA) at 15 Mhz and inputting parallel data on the rising edge. I could probably get twice that by inputting data on both edges.

I agree with your concerns about expecting two independent clocks to remain synchronized.
 
Hi and Welcome,

For what it is worth, there are a few of us who have played around with reading in a couple of the cameras using DMA on the Teensy 4.xs...
A lot of it has been done using the OV7670 using 8 bit captures.

For 8 bits on T4.1 we have the option of using the CSI subsystem, but unfortunately, the T4.1 only brought out the CSI_D2 through CSI_D9 which are the ones used in 8 bit mode, the bits for D0 and D1 were not brought out to actual IO pins.. So won't work for you, unless you can go with 8 bit color mode.

We also played with it using GPIO and DMA.
Some of may playing is up at: https://github.com/KurtE/Arduino_OV767X/tree/Teensy_t4_dma-hold (but not sure if this branch or the micromod version is more up to date)... Been awhile.

From my excel document I played with a few different pin configurations...
But I liked the one where

Code:
Pin	Name	GPIO	Serial	I2C	SPI	PWM	CAN	Audio	XBAR	FlexIO	Analog	SD/CSI/LCD
 1	AD_B0_02	1.02	Serial1(6) TX		SPI1(3) MISO	PWM1_X0	2_TX		IO-16			
 0	AD_B0_03	1.03	Serial1(6) RX		SPI1(3) CS0	PWM1_X1	2_RX		IO-17			
24/A10	AD_B0_12	1.12	Serial6(1) TX	Wire2(4) SCL		PWM1_X2					A1:1  	
25/A11	AD_B0_13	1.13	Serial6(1) RX	Wire2(4) SDA		PWM1_X3	GPT1_CLK				A1:2	
19/A5	AD_B1_00	1.16	Serial3(2) CTS	Wire(1) SCL		QT3_0				3:0	A1:5, A2:5	
18/A4	AD_B1_01	1.17	Serial3(2) RTS	Wire(1) SDA		QT3_1				3:1	A1:6, A2:6	
14/A0	AD_B1_02	1.18	Serial3(2) TX			QT3_2		SPDIF_OUT		3:2	A1:7, A2:7	
15/A1	AD_B1_03	1.19	Serial3(2) RX			QT3_3		SPDIF_IN		3:3	A1:8, A2:8	
40/A16	AD_B1_04 	1.20								3:4	A1:9,A2:9	USDHC2_DATA0
41/A17	AD_B1_05 	1.21				GPT2_1				3:5	A1:10,A2:10	USDHC2_DATA1
17/A3	AD_B1_06	1.22	Serial4(3) TX	Wire1(3) SDA				SPDIF_LOCK		3:6	A1:11, A2:11	USDHC2_DATA2
16/A2	AD_B1_07	1.23	Serial4(3) RX	Wire1(3) SCL				SPDIF_EXTCLK		3:7	A1:12, A2:12	USDHC2_DATA3
[COLOR="#FF0000"]22/A8	AD_B1_08	1.24				PWM4_A0	1_TX			3:8	A1:13, A2:13	USDHC2_CMD
23/A9	AD_B1_09	1.25				PWM4_A1	1_RX	1:MCLK		3:9	A1:14, A2:14	USDHC2_CLK
20/A6	AD_B1_10	1.26	Serial5(8) TX					1:RX_SYNC		3:10	A1:15, A2:15	
21/A7	AD_B1_11	1.27	Serial5(8) RX					1:RX_BCLK		3:11	A1:0, A2:0	
38/A14	AD_B1_12 	1.28			SPI1(3) CS0 			1:rx_data 		3:12	A2:1	
39/A5	AD_B1_13 	1.29			SPI1(3) MISO			1:tx_data 		3:13	A2:2	
26/A12	AD_B1_14	1.30			SPI1(3) MOSI			1:TX_BCLK		3:14	A2:3  	
27/A13	AD_B1_15	1.31			SPI1(3) SCK			1:TX_SYNC		3:15	A2:4  	[/COLOR]
10	B0_00	2.00			SPI(4) CS0	QT1_0		MQS_RIGHT		2:0     		
12	B0_01	2.01			SPI(4) MISO	QT1_1		MQS_LEFT		2:1     		
11	B0_02	2.02			SPI(4) MOSI	QT1_2	1_TX			2:2		
13	B0_03	2.03			SPI(4) SCK	QT2_0	1_RX			2:3		
6	B0_10	2.10				PWM2_A2, QT4_1		1:TX3_RX1		2:10		
 9	B0_11	2.11				PWM2_B2,QT4_2		1:TX2_RX2		2:11		
32	B0_12	2.12						1:TX1_RX3	IO-10	2:12		
8	B1_00	2.16	Serial2(4) TX			PWM1_A3		1:RX_DATA	IO-14	2:16, 3:16		
7	B1_01	2.17	Serial2(4) RX			PWM1_B3		1:TX_DATA	IO-15	2:17, 3:17		
36	B1_02    	2.18			SPI(4) CS2 	PWM2_A3		1:TX_BCLK 	IO-16	2:18,3:18		
37	B1_03    	2.19			SPI(4) CS1 	PWM2_B3		1:TX_SYNC 	IO-17	2:19,3:19		
35	B1_12    	2.28	Serial8(5) TX							2:28,3:28		
34	B1_13    	2.29	Serial8(5) RX							2:29,3:29		
45	SD_B0_00	3.12		Wire1(3) SCL	SPI2(1) SCK	PWM1_A0			IO-04			CMD
44	SD_B0_01	3.13		Wire1(3) SDA	SPI2(1) CS0	PWM1_B0			IO-05			CLK
43	SD_B0_02	3.14	Serial5(8) CTS		SPI2(1) MOSI	PWM1_A1			IO-06			DATA0
42	SD_B0_03	3.15	Serial5(8) RTS		SPI2(1) MISO	PWM1_B1			IO-07			DATA1
47	SD_B0_04	3.16	Serial5(8) TX		FLEXSPI B_SSO_B	PWM1_A2			IO-08			DATA2
46	SD_B0_05	3.17	Serial5(8) RX		FLEXSPI B_DQS	PWM1_B2			IO-09			DATA3
28	EMC_32	3.18	Serial7(7) RX			PWM3_B1						
31	EMC_36	3.22				GPT1_2	3_TX	3:TX_DATA	IO-22			
30	EMC_37	3.23				GPT1_3 	3_RX	3:MCLK	IO-23			
 2	EMC_04	4.04				PWM4_A2		2:TX_DATA	IO-06	1:4		
 3	EMC_05	4.05				PWM4_B2		2:TX_SYNC	IO-07	1:5		
 4	EMC_06	4.06				PWM2_A0		2:TX_BCLK	IO-08	1:6		
33	EMC_07	4.07				PWM2_B0		2:MCLK	IO-09	1:7		
5	EMC_08	4.08				PWM2_A1		2:RX_DATA	IO-17	1:8		
51	EMC_22	4.22		Wire1(3) SCL	FLEXSPI2_A_SS1_B	PWM3_B3, QT2_3						
48	EMC_24	4.24	Serial8(5) RX 		FLEXSPI2_A_SS0_B	PWM1_B0						
53	EMC_25	4.25	Serial1(6) TX 		FLEXSPI2_A_SCLK	PWM1_A1						
52	EMC_26	4.26	Serial1(6) RX 		FLEXSPI2_A_DATA00	PWM1_B1				1:12		
49	EMC_27	4.27	Serial8(5) RTS		FLEXSPI2_A_DATA01, SPI2(1) SCK  	PWM1_A2				1:13		
50	EMC_28	4.28	Serial8(5) CTS		FLEXSPI2_A_DATA02, SPI2(1) MOSI	PWM1_B2				1:14		
54	EMC_29	4.29	Serial1(6) RTS		FLEXSPI2_A_DATA03, SPI2(1) MISO	PWM3_A0				1:15		
29	EMC_31	4.31	Serial7(7) TX		SPI2(1) CS1	PWM3_A1
I had it such that the LSB bit was GPIO 1.31 and after the DMA operation, I reversed the bits using one assembly language instruction... The two previous GPIO pins are also available...

On the Beta version of the Sparfun Teensy MicroMod we did it two ways as well. But we were mostly playing with the Himax monochrome camera and doing it with either 4 bit or 8 bit access using FlexIO.
Also had version of this code working using GPIO DMA as well.

A lot of the code for that is up in the github project: https://github.com/mjs513/TMM-HB01B0-Camera And lots of the details in the Micromod beta forum thread.
 
Status
Not open for further replies.
Back
Top