Downloading external program from MC9S12C128 to Avago mouse sensor

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Downloading external program from MC9S12C128 to Avago mouse sensor

跳至解决方案
916 次查看
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 解答
547 次查看
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 回复
548 次查看
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 项奖励
回复