Other Parts Discussed in Thread: MSPM0L1306, SYSCONFIG, LP-MSPM0C1104, MSPM0C1104
Tool/software:
Hardware Setup:
For AM62L EVM:
Connect type-C power supply.
Connect UART-to-USB and USB for JTAG XDS110 to your computer.
For LP-MSPM0:
Connect power supply cum XDS110 to your computer.
Connect analog signal input to J3_PA18 (ADC0_7) in Launchpad MSPM0Lx.
Connect analog signal input to J3_PA16 (ADC0_8) in Launchpad MSPM0Lx (if needed).
For inter-board connections:
Connect pin-28 (SPI1_D0_EXP) in AM62L EVM User Expansion Connector to J2_PA4 (SPI_POCI) in Launchpad MSPM0Lx.
Connect pin-29 (SPI1_D1_EXP) in AM62L EVM User Expansion Connector to J2_PA5 (SPI_PICO) in Launchpad MSPM0Lx.
Connect pin-27 (SPI1_CLK_EXP) in AM62L EVM User Expansion Connector to J1_PA6 (SPI_CLK) in Launchpad MSPM0Lx.
Connect pin-30 (SPI1_CS0_EXP) in AM62L EVM User Expansion Connector to J2_PA3 (SPI_CS(PWM)) in Launchpad MSPM0Lx.
Software Setup:
Enabling SPI in Linux on AM62L
Linux Configuration:
Apply the following patch in ti-linux-kernel repo within AM62L SDK:
diff --git a/arch/arm64/boot/dts/ti/k3-am62l3-evm.dts b/arch/arm64/boot/dts/ti/k3- am62l3-evm.dts index f5cdb9420..6780d31c1 100644 --- a/arch/arm64/boot/dts/ti/k3-am62l3-evm.dts +++ b/arch/arm64/boot/dts/ti/k3-am62l3-evm.dts @@ -375,6 +375,15 @@ AM62PX_IOPAD(0x018c, PIN_INPUT, 0) /* (B9) MCASP0_AXR0 */ AM62PX_IOPAD(0x0188, PIN_INPUT, 0) /* (A9) MCASP0_AXR1 */ >; }; + + main_spi1_pins_default: main-spi1-pins-default { + pinctrl-single,pins = < + AM62LX_IOPAD(0x008c, PIN_INPUT, 4) /* (H22) SPI1_CLK */ + AM62LX_IOPAD(0x0080, PIN_INPUT, 4) /* (K22) SPI1_D0 */ + AM62LX_IOPAD(0x0084, PIN_INPUT, 4) /* (J23) SPI1_D1 */ + AM62LX_IOPAD(0x0088, PIN_INPUT, 4) /* (K23) SPI1_CS0 */ + >; + }; }; &main_uart0 { @@ -902,3 +911,26 @@ &mcasp0 { 0 0 0 0 >; }; + +&main_spi1 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&main_spi1_pins_default>; + spidev@0 { + spi-max-frequency = <24000000>; + reg = <0>; + compatible = "rohm,dh2228fv"; + }; +}; + + +&main_i2c1 { + gpio@23 { + fet_sel { + gpio-hog; + gpios = <1 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "VOUT0_FET_SEL0"; + }; + }; +}; diff --git a/kernel/configs/ti_arm64_prune.config b/kernel/configs/ti_arm64_prune.config index 9bca0b9f3..7a19f5486 100644 --- a/kernel/configs/ti_arm64_prune.config +++ b/kernel/configs/ti_arm64_prune.config @@ -486,3 +486,4 @@ CONFIG_DVB_TDA665x=n CONFIG_DVB_DRX39XYJ=n CONFIG_DVB_CXD2099=n CONFIG_DVB_SP2=n +CONFIG_SPI_SPIDEV=y \ No newline at end of file
Rebuild linux and install Image, dtbs and modules on SD/eMMC.
Userspace Application:
Use and compile the following C file in Linux Userspace: https://github.com/TexasInstruments/Beyond-SDK/tree/main/am62x/MSPM0-ADC-RTC-Attach/MSPM0-ADC-Attach-SPI/Single%20Byte%20Single%20Channel%20SPI/Controller/AM62x%20-%20A53%20Core%20MAIN%20Domain
Enabling SPI in Linux on MSPM0Lx
Refer to this section https://www.ti.com/document-viewer/lit/html/SLAAEJ0#GUID-08804ED8-50F6-486D-865C-CFBF1651387E/GUID-AE9E2CF5-CF8A-4813-A9A4-737A5EA4AB09 and import the Single_Byte_Single_Channel_SPI/Peripheral/MSPM0 CCS project.
On the newer MSPM0 SDK versions, this may give build errors. To resolve this, import a fresh spi_peripheral_echo_interrupts_LP_MSPM0L1306_nortos_ticlang project using Resource Explorer in CCS and then:
1. copy the spi_peripheral_echo_interrupts.c from Beyond SDK to the fresh project.
2. copy the sysconfig setting as in Beyond SDK for ADC12, SPI, TIMER, and EVENT in the fresh project.
This should build without errors.
Running Demo
On MSPM0L, follow from step3 onwards as given at https://www.ti.com/document-viewer/lit/html/SLAAEJ0#GUID-1E37DB3D-FD4F-4A5C-A2CA-9730C78677D1/GUID-254DC168-0287-4E6D-B2DC-19A5F14F83CD
On AM62L, run the following command:
./spidev_adc_multibyte_multichannel -D /dev/spidev0.0 -s 12000000 -v