PIC12F675 code doesnt work

Status
Not open for further replies.

Flyback

Well-Known Member
Hello

Do you know why this C code for PIC12F675 doesn’t work?

Its using XC8 C

All it does is make GP0 = 0 if the ADC reads the ‘busvoltage’ variable as being greater than 0x19. If the ‘busvoltage’ variable is less than 0x19 then it should make GP0 = 1;


However, it does not work.

I think its the ADC function doADC(); ...but i am not sure.


When i don’t call the doADC function i have got it able to oscillate the GP0 output. (but i don’t want the code to do that, we want the code to read ADC and act accordingly.)


 
You seem to have the ADC set to left justify but only read the low byte of ADRES. This means you only read two bits.

Mike.
 
for (count=35; count=0; count--) {

This looks completely wrong to me. Try...

for (count = 35 ; count > 0; count--) {

And same change for the other similar functions.
 
You also need to check CS. In zeropot you leave it low and dont set it high in your various other routines.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…