How can I toggle the CS pin of SPI ports in K40x microcontroller at a certain rate ?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How can I toggle the CS pin of SPI ports in K40x microcontroller at a certain rate ?

ソリューションへジャンプ
2,897件の閲覧回数
kbm
Contributor I

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.

ラベル(1)
タグ(2)
0 件の賞賛
返信
1 解決策
2,594件の閲覧回数
BlackNight
NXP Employee
NXP Employee

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

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
2,594件の閲覧回数
BlackNight
NXP Employee
NXP Employee

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

2,594件の閲覧回数
kbm
Contributor I

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.

test_pic.png

0 件の賞賛
返信
2,594件の閲覧回数
BlackNight
NXP Employee
NXP Employee

You set the SPI clock here:

pastedImage_0.png

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

2,594件の閲覧回数
kbm
Contributor I

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

0 件の賞賛
返信
2,595件の閲覧回数
BlackNight
NXP Employee
NXP Employee

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

0 件の賞賛
返信
2,594件の閲覧回数
kbm
Contributor I

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 ?

0 件の賞賛
返信