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?
Solved! Go to Solution.
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
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