Hi All,
I am using PE with CodeWarrior to set the SPI port of microcontroller using in K40x256 tower system. Could anyone please explain how I can toggle the CS pin of the SPI port at a certain rate ? I need this to interface with a certain ADC.
Solved! Go to Solution.
Simply have the CS pin disabled:
The you can use the CS pin any way you want (e.g. as a Bit I/O pin).
Erich
Hello,
you can use the CS pin as a normal general purpose pin. A simple solution would be to set up a timer interrupt with a given rate, and then toggle the CS pin from the interrupt service routine. You can check as well if that CS pin can be muxed say with a timer-out channel. If so, you could simply use a PWM signal to toggle the pin (e.g. Tutorial: PWM with Processor Expert).
Erich
Hi Erich,
Thanks a lot ! I was wondering how I can change the clk rate of SPI ? I tried but it seems that the values are unachievable with the current settings.
You set the SPI clock here:
The clock path is only to illustrate how that clock is built up.
Processor Expert can automatically select the prescalers for you, so you do not need to do this by hand.
Erich
Thanks again ! In relation to the SPI pin how can I check if the CS pin can be MUXED ? In PE Components, there is an option CS demultiplexer but no option for multiplexer
Simply have the CS pin disabled:
The you can use the CS pin any way you want (e.g. as a Bit I/O pin).
Erich
Very helpful. Thanks !! I have got the SPI working now.. About handling data coming through the SPI, I have two ways to handle..
1. Pass from SPI to memory using DMA. Then from memory to PC using UART.
2. Pass from SPI directly to other SPI2. Then from SPI2 to PC.
Could you please let me know how I can implement 1 and 2. Could you please point to any tutorials ? Also, could you please with documentation for the microcontroller used in K40x256 as I am unable to find one, especially describing SPI and other peripherals..
Also,
Is there any way in Code Warrior I can watch variables in run time such as some compilers have the option of Live Watch ?