PIC32MX795F512L 12bit SPI can't be done?

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
jks45
Posts: 7
Joined: 08 Dec 2018 22:37

PIC32MX795F512L 12bit SPI can't be done?

#1 Post by jks45 » 08 Dec 2018 23:16

I fear that using the 8, 16 or 32 bit SPI routines won't allow the "Read memory register in User Mode". "Read angle data in Normal Mode" works perfectly by holding CS low and using 8 bit write then 16 bit read.

SPI3_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 1024, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_ACTIVE_2_IDLE)
SPI_Set_Active(@SPI3_Read, @SPI3_Write)
Chip_Select = 0
SPI3_Write(OPcode) ' 4 bits + 0000

SPI3_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, 1024, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_ACTIVE_2_IDLE)
SPI_Set_Active(@SPI3_Read, @SPI3_Write)
capturedSPIWORD = SPI3_Read(SPIWORD)
Chip_Select = 1
' NEED TO MASK OFF 4 BITS (MD,P1,P2,E)
capturedSPIWORD = capturedSPIWORD and 0x0fff

There is not a big enough break between MOSI and MISO data (12/24bits) to use this method for the "Read memory register in User Mode". I hope I don't have to bitbang to accomplish this.
Attachments
SPI format 12 bits
SPI format 12 bits
SPI 32 read.JPG (49.95 KiB) Viewed 1220 times

jks45
Posts: 7
Joined: 08 Dec 2018 22:37

Re: PIC32MX795F512L 12bit SPI can't be done?

#2 Post by jks45 » 15 Dec 2018 01:41

Has anyone encountered this problem before? Do I need to clarify anything? I was hoping there might be a solution before I have to bit bang the SPI function to access more data from the device I'm using. One other question was how to undo the SPI function I have already enabled with "SPI_Set_Active(@SPI3_Read, @SPI3_Write)". Must I deactivate it before bit banging?

Post Reply

Return to “mikroBasic PRO for PIC32 General”