ATD1SC=0x41; //Select ATDCO=1 and CH1
This code doesn't do what the commet says, but instead it enables interrupts, which you don't handle in your code, and it sets channel to AD0. This is why you shouldn't setup register with hex values, but with pre-defined bit masks.
void delay(void){
uint I,j,k;
for(I=0;I<1000;I++)
for(j=0;j<500;j++)
k++;
}
This function does nothing and the compiler will most likely optimize it away entirely. I would strongly suggest using hardware timers instead. If you insist on keeping this burn-away loop, you must make all loop iterators volatile or there are no guarantees it will work.