Hi! Support,
Because I need to use SPI as a master to talk to a few devices on the SPI bus, is there a way I can make SS runs like a GPIO and manually drive the bus to high or low? I am using Kinetis KL25 freedom board. Thanks!
Vincent
Hi! Jorge,
Thanks! I have already been able to read and write SPI slave through setting SS pin as a GPIO. Thanks for your help!
Vincent
Hi! Jorge,
I tried the way you suggest except
SPI0_C2 &= ~SPI_C2_MODFEN_MASK;
Is this a necessary command I should add inside my program? Will there be any potential problem if I did not add that? If I want to add that, should I add that in my main routine inside ProcessExpert.c right after Low Level Init program?
Vincent
Hello Vincent:
By checking again, I think I misunderstood the reference ranual, sorry about that. It indicates that MODFEN should be 0 in order to release the SS pin as GPIO, but I guess that this is only when you configure a specific pin to perform the SS function, which is not the case here, because you do not define any pin to be the SS input/output.
So, in conclusion that code should not be neccessary. Did you already try and you were able to control the pin?
Regards!
Jorge Gonzalez
Hi! Jorge,
Thanks! I am able to manage it. I only have one issue regarding SPI communication flow. Because SS pin is not managed by SPI component anymore, I don't have the mechanism to judge whether the data transmission has been completed.
I used the method, Get_BlockSentStatus to get the end of the transmision and pull up my GPIO after I get success from the method. From the Logic Analyzer, I discovered the SS line is pulled up even before the data been sent to the slave. As a result, I could only use a loop to wait for a certain period of time to wait until the process is completed. Do you have any idea about the correct mechanism to manage the SS pin's level if we use GPIO to act as an SS pin? Thanks!
Vincent
Hi Vincent:
There is a thread with the same problem with the GetBlockSentStatus method: This is for the K20 MCU, but might give you an idea of how to modify your code:
Re: Is anyone really using PE Generated SPI driver with MQXLite? How?
Regards!
Jorge Gonzalez
Hello Vincent:
If you want to control chip select signal (SS) via GPIO instead of automatically by the SPI module, first set your chip select list to 0.
:smileyalert:EDITED: MODFEN has no meaning when no pin is selected as SS (Chip Select List = 0).
Now you can configure the pin for GPIO functionality, by adding a BitIO_LDD component, or setting the pin yourself.
Hope this is useful!
Jorge Gonzalez