Ping Ultra Sonic sensor with MC9S12DG256

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Ping Ultra Sonic sensor with MC9S12DG256

1,957件の閲覧回数
JoeD_
Contributor I
I'm using the iccv7 compiler for the MC9S12DG256 and I'm trying to help my buddy by programming it to use the Ping Ultra Sonic Sensor from Parallax. I've successfully coded it for a basic Stamp, but now when I'm trying to code it in C in iccv7 I'm having problems with the PORT T timer. I'm at work right now so I'm not able to paste up the code, I will do that once home, but I was just wondering if anyone has ever used this sensor before any may have examples. Thanks for any help!


Joe
ラベル(1)
0 件の賞賛
返信
1 返信

874件の閲覧回数
JoeD_
Contributor I
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



0 件の賞賛
返信