ISP issues sprung up

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Out of the blue it just stopped working, now I get ISP error every time. ISP is set to 125kHZ, clock is at 8MHz. Below is my code, but I don't think that could cause ISP errors. I also have power. Any ideas?

#include       

int main(void) 
{ 
     DDRB |= (1 << 0);   //Sets Port Bit 0 as output

     ADCSRA |= (1 << ADPS2) | (1 << ADPS1);      //ADC Prescalar set to 64 - 125kHz@8MHz 

     ADMUX |= (1 << REFS2) | (1 << REFS1);      //Sets ref. voltage to 2.56v internal reference 
     ADMUX |= (1 << ADLAR);       // Left adjust ADC result to allow easy 8 bit reading 
     ADMUX |= (1 << MUX1);   	//Selects channel ADC2 (PB4) = binary 0010

     ADCSRA |= (1 << ADEN);  // Enable ADC 

  while (1) //loop while 1
  { 
  ADCSRA |= (1 <<ADSC);	//Starts ADC conversion for single ended mode
  while (ADCSRA & (1 << ADSC) );	// 
 if(ADCH > 128)		//If ADCH >  (64x10mv = 1.28v) then Port Bit 0 and 2 are on.
      { 
         PORTB |= (1 << 0); // Turn on Port Bit 0 
      } 

      else 
      {  
        PORTB &= ~(1 << 0); // Turn off Port Bit 0
     } 
  } 
} 

//Notes: 2.56v/256 = 10mV resolution in 8-Bit mode