SPI problem PIC32MX250F128D
Posted: 30 Sep 2020 10:01
Hi,
I have a strange problem with SPI1 when i enable USB HID.
This works:
' Initialize SPI1 module SD Card
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 80, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE)
SPI1_Write(0xb0)
Delay_ms(1000)
' Initialize USB HID
USBIE_bit = 1
USBIP2_bit = 1 ' Interrupt priority 7
USBIP1_bit = 1 ' Interrupt priority 7
USBIP0_bit = 1 ' Interrupt priority 7
' Enable all interrupts
EnableInterrupts
HID_Enable(@HidReadBuff, @HidWriteBuff) ' Enable USB HID communication.
This Does not work:
' Initialize USB HID
USBIE_bit = 1
USBIP2_bit = 1 ' Interrupt priority 7
USBIP1_bit = 1 ' Interrupt priority 7
USBIP0_bit = 1 ' Interrupt priority 7
' Enable all interrupts
EnableInterrupts
HID_Enable(@HidReadBuff, @HidWriteBuff) ' Enable USB HID communication.
Delay_ms(1000)
' Initialize SPI1 module SD Card
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 80, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE)
SPI1_Write(0xb0)
When SPI1 is initialized after HID_Enable function it blocks the SCLK output but MOSI works?
If i move the project to another Microcontroller PIC32MX534F064H that is used on PIC32MX clicker, both versions work!
Any suggestions?
I have a strange problem with SPI1 when i enable USB HID.
This works:
' Initialize SPI1 module SD Card
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 80, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE)
SPI1_Write(0xb0)
Delay_ms(1000)
' Initialize USB HID
USBIE_bit = 1
USBIP2_bit = 1 ' Interrupt priority 7
USBIP1_bit = 1 ' Interrupt priority 7
USBIP0_bit = 1 ' Interrupt priority 7
' Enable all interrupts
EnableInterrupts
HID_Enable(@HidReadBuff, @HidWriteBuff) ' Enable USB HID communication.
This Does not work:
' Initialize USB HID
USBIE_bit = 1
USBIP2_bit = 1 ' Interrupt priority 7
USBIP1_bit = 1 ' Interrupt priority 7
USBIP0_bit = 1 ' Interrupt priority 7
' Enable all interrupts
EnableInterrupts
HID_Enable(@HidReadBuff, @HidWriteBuff) ' Enable USB HID communication.
Delay_ms(1000)
' Initialize SPI1 module SD Card
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 80, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE)
SPI1_Write(0xb0)
When SPI1 is initialized after HID_Enable function it blocks the SCLK output but MOSI works?
If i move the project to another Microcontroller PIC32MX534F064H that is used on PIC32MX clicker, both versions work!
Any suggestions?