I am looking for help on averaging a adc reading in assembly language
Just not sure how to do it ,,I had a go at adding 4 values together then rotate right but it didnt work correct
If anyone knows of a good tutorial or code snippets i would be very thankfull
cheers
bjay
Hi,
you are very close. It is shifting right though, not rotating. Rotating right brings the least significant bits back into the game a most significant bits. Shifting right by 2 just discards of the 2 LSBs
hi,
in C language
unsigned int16 xin[5] ;
{
xin[4]=xin[3];
xin[3]=xin[2];
xin[2]=xin[1];
xin[1]=xin[0];
xin[0]=read_adc();
volt=(xin[0]+xin[1]+xin[2]+xin[3]+xin[4])/5;
The adc works well at the moment
I was just trying to make it a little better by taking a few readings then divide
I have read a little about rolling averages but i wanted to keep it simple
I have been looking at c code of late, but you go back to what you are comfortable in
Thanks for the reply millwood