View previous topic :: View next topic |
Author |
Message |
necati
Joined: 12 Sep 2003 Posts: 37 Location: istanbul
|
PYD1998 read |
Posted: Sat Jun 16, 2012 4:26 am |
|
|
Code: |
#define IRSENSE_IO PIN_C4 //
int8 i,j;
int16 data=0,dat;
void PYD1998(void){
data=0;
input(IRSENSE_IO);
while(!input(IRSENSE_IO)){
for (j=0; j < 60; j++); // wait appr. 30 :sec (tS)
for (i=0; i < 15; i++){ // 15 Bits, MSB is low
//output(IRSENSE_IO); //configure Pin as output;
output_low(IRSENSE_IO); //set dl low for >200 ns;
delay_cycles(25);
output_low(IRSENSE_IO);//set dl high for >200 ns;
delay_cycles(25);
output_high(IRSENSE_IO);
input(IRSENSE_IO); //configure Pin as input;
Data <=1; // shift Bits left
if(input(IRSENSE_IO)){data ++ ;} // read Hi
}
output_low(IRSENSE_IO);
delay_cycles(200);
input(IRSENSE_IO);
delay_cycles(200);
dat=data;
}
}
|
Where is my wrong ?
http://www.excelitas.com/downloads/app_digipyropyq2898_0208.pdf |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jun 16, 2012 10:22 pm |
|
|
That appnote has a flowchart and sample code. Why don't you translate
it to CCS, instead of inventing your own code ? |
|
|
sabobey
Joined: 19 Oct 2008 Posts: 6
|
How do I need to write Pyd1998 pic12f675. |
Posted: Sun Jul 29, 2012 2:05 pm |
|
|
PCM programmer wrote: | That appnote has a flowchart and sample code. Why don't you translate
it to CCS, instead of inventing your own code ? |
How do I need to write Pyd1998 pic12f675
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Sun Jul 29, 2012 5:10 pm |
|
|
Seems no one wants to cut code anymore....and the example is done in C nonetheless so it's very easy to 'port' over to CCS C unlike 'translating' it from say BASIC, assembler, etc. |
|
|
|