Downloading external program from MC9S12C128 to Avago mouse sensor

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

Downloading external program from MC9S12C128 to Avago mouse sensor

ソリューションへジャンプ
1,065件の閲覧回数
JonathanB
Contributor I

This is the first time I've posted in the forum so hopefully it's in the right bit!

 

I'm currently writing code in C using Codewarrior for an MC9S12C128 which will control an Avago mouse sensor. I have a 2Kb text file containing ASCII values which make up the configuration program for the mouse sensor. I'm trying to work out the best way to download this data to the mouse chip. I am using SPI from the microcontroller. The first byte of data sent via the MOSI line is the sensor's register, and then the program should be presented on the MOSI line one byte at a time.

 

I think the best way to do this is to store the program into an array of chars, but I can't work out how to translate a text file with each line containing a 2-character byte into an array without manually copying the ASCII data into Codewarrior. Is there an easy way to do this?

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
696件の閲覧回数
pgo
Senior Contributor V

Dear Jonathon,

 

One method I've used to do something similar is to write a simple PC based program to translate the original file into a 'C array' i.e. reformat the information as a mouseData.h file that can be #included in the C code.  The program would just produce something similar to the following:

 

 

const char mouseData[] = {0x12, 0x34, 0x56,};

 

 

This would be a very simple program and could be re-run if you need to change the data.

 

bye

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
697件の閲覧回数
pgo
Senior Contributor V

Dear Jonathon,

 

One method I've used to do something similar is to write a simple PC based program to translate the original file into a 'C array' i.e. reformat the information as a mouseData.h file that can be #included in the C code.  The program would just produce something similar to the following:

 

 

const char mouseData[] = {0x12, 0x34, 0x56,};

 

 

This would be a very simple program and could be re-run if you need to change the data.

 

bye

0 件の賞賛
返信