PIC analogue to serial interface

I have started looking at PIC programming again, tried to write the firmware I had written before for the 16F688, but there were compile errors. I appear to have sorted the compiling issues and able to program the device but it doesn't seem to work as I had it before. I am using a newer version of both MPLAB and Hi-Tech compiler. I can't see where the problem is. I tried stripping the firmware down to just flash an LED (so I can build it up from there again) but I can't seem to do that right. Any help would be appriciated.

MPLAB IDE 8.83
Hi-Tech Universal Toolsuite 9.83

Thanks,

Jules.
 

Attachments

The only thing that sticks out.... ADC_CH0 doesn't start at 0.. also when you assigned channel[k] k never increases ... It's always 0.

I'm going to run it through ISIS.... I'll get back to you.... Are you still using the pic16f688?
 
I've double checked things with the PICKIT1 and 16F688 datasheets and it seems ok, besides I don't understand why I had it working a year ago (and still have a programmed 16F688 that works). Is there a way to get the program back from the PIC? Or can you check what I want it to do is what the code actually says.

To Ian Rogers:

The trimmer is connected to AN0/RA0 pin so I want the code to read from that input, is that what my code is doing or did you mean I'm reading from the wrong place?

I thought "k++;" on line 94 increments k. Correct me if I'm wrong.

I have several 16F688s as that seems to be the only one that has a hardware USART and can be programmed with a PICKIT1.

I have checked the pic16f688.h file (attached) for the __CONFIG and I believe FOSC_INTOSCIO means to use the internal oscillator, which i want to do.


Another idea I had was that the (pro trial) Hi-Tech compiler is optimising the code without me knowing it. Is there a better way to make it read AN0 and output it on the serial (RS232) once a second?

Thanks,

Jules.
 

Attachments

Yes Burt... I should have explained that... Thanks
I thought "k++;" on line 94 increments k. Correct me if I'm wrong.

Yes but you immediately turn it back to 0.

Code:
   k++;
   if (k == 1) k = 0;
   break;

I have tried this in ISIS and it works very well.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…