I run the below loop in main().
I use a subroutine called Get_ADC_Raw() that utilizes the SW_I2C bean to gets data from a outside IC.
The below code will work for me – the data from Get_ADC_Raw() is put into a variable OutX Then this data is pushed out to my screen by the subroutine OutputRawtoScreen()
What I would like to do is take that data which is in variable OutX and do a couple of calculations, the last calculation is a log10().
The below code works - (only because set the OutX variable to a fixed value) I get the correct data from the Get_ADC_Raw() - it outputs correctly to the screen for me and the other calculation including the log10() work fine for me. Now if I eliminate the line “OutX = 4000” and just try to use the raw data that should be in that variable it seems to mess up the data that comes out of the Get_ADC_Raw() routine.
This is probably something simple I’m doing wrong and have worked the last couple of days to try and solve the problem without success.
My original project and code was developed around the MC9S08QE128 processor and it worked fine and was pretty much complete - I only started to have issues when I switched to the MC9S08JM60 processor (I needed USB capabillity). I'm sure it is probably something simple like an initialization that I need to take care of but I just can't find the solution.
Below is a basic run down of the code which has subroutines that are placed in other .c files that I link using .h files.
I am new to this forum and this is my first post so I apolgize if my explanation of my issue is not clear.
Any help would be be much appreicated - thanks!
unsigned int OutX;
OutX = Get_ADC_Raw(); //get data from SW_I2C bean
OutputRawtoScreen(OutX); //output that data to my display
OutX = 4000; //set the variable to 4000
logVal = OutX/32.767; //divide the var value by 32.767 and out into logVal
logVal = logVal/1000; //divide the logVal by 1000 and place back in logVal
logOut = 10*log10(logVal); // do a log10 conversion on the logVal and place in logOut