We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm trying to read the data from an ADC. I'm getting the error message error C193 '+=' bad operand type. If I use '=+' I don't get the error but my data is shifting. My result is a 0 or 1. It should be in the range from 0 to 255. CONVST is the convert command I'm sending to the ADC, SCLK is the clock pulse I'm sending to the ADC, DOUT is the data coming from the ADC, and ad_in is my variable. Any help would be appreciated. Here it the part of the program that's giving me the trouble. void read_ad(void) { data byte i; SCLK = 1; CONVST = 0; ad_in = 0; CONVST = 1; i=8; do { SCLK = 0; ad_in<<=1; SCLK = 1; ad_in += DOUT; } while(--i); }
Try
ad_in += (byte)DOUT;