I use spi slave as communication interface ,i need to detect CS pin Rising edge and falling edge ,but spi registor Doesn't seem to support, can provide way to detect ?
If you want to independently detect in your application the edges of CS you can connect another GPIO configured as input to CS. That pin should be configured to trigger interrupt request.
If you are using SDK and ProcessorExpert you should configure your GPIO like in this picture:
To install the interrupt request you must call these 2 functions in your application: INT_SYS_InstallHandler();INT_SYS_EnableIRQ();
HI , i have try it as General GPIO ,but spi_slave_irq can not enter
so , spi slave mode can No CS detection required? that means spi slave can not config cs pin ?
Ok, now I understand your issue. I suppose that you want to use PCS events for other things.
Can you take a look at the example project provided by SDK? There is an example which shows how to configure spi master and slave.
The reasons for your problems can be: wrong polarity of the CS, bad handling of interrupt (flags and NVIC) or pins configuration.
Re-combing the SPI slave problem now encountered
- 1 I am now doing the following configuration for SPI slave
I use the following spi slave send interface to send a single byte
LPSPI_DRV_SlaveTransfer(USE_SPI_INSATNCE,(const uint8 *)&send,(uint8 *)&rcv,(uint16)1);
When my spi master sends a byte of data, the slave can enter the interrupt, as shown below
- 2 When the chip select is configured as a normal GPIO port
When my spi master sends a byte of data, the slave can enter the interrupt transmit error, as shown below
So I have doubts, can the spi slave CS select pin can be used as normal GPIO for rising edge and falling edge detection, reading SPI slave data？
The right approach to make LPSPI to work fine is the first one. I have only one suggestion: please set the direction as input for PTB0.
I have suggested to use another GPIO (not PTB0) if you want to detect rising and falling edges for other purpose than LPSPI data transfers.
If this answer doesn't help you please try to provide details about your usecase to figure out how you should configure SDK drivers.
I have solved this way. First, PB0 is configured as the CS pin of the hardware, and then when the software is initialized, it is configured as a bilateral edge trigger.
Here is my code
PINS_DRV_SetPinIntSel(PORTB, 0, PORT_INT_EITHER_EDGE); /* Install hander for spi_master_Det ISR */ INT_SYS_InstallHandler(PORTB_IRQn, spi_cs_det, (isr_t *)0); /* Enable button spi_master_Det IRQ */ INT_SYS_EnableIRQ(PORTB_IRQn); INT_SYS_SetPriority(PORTB_IRQn, 1);
Retrieving data ...