so i gave up an the timer control and now i'm trying to manually do it. Heres my code
DDRH = 0x80; // PH7 out
PPSH = 0x80; // pull-DOWN PH7
PERH = 0x80; // enable them
PTH = 0x80;
delay10u();
PTH = 0x00;
DDRH = 0x7F; // PH7 in
PPSH = 0x80; // pull-DOWN PH7
PERH = 0x80; // enable them
PTH = 0x00;
while(1)
{
if (PTH &0x80)
{
while(PTH &0x80){i ++;} //Sit and wait for falling edge
printf("%d\n\r" ,i );
i = 0;
}
}
All I'm trying to do here is pulse a 1 out for 10us which enable the SRF05, then switch port h pin 7 back to input and wait for to go back high then increment i while high, and based of the count of i, i can determine the distance.
SRF05 datasheet