CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

TSL1406R and 18F252

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

TSL1406R and 18F252
PostPosted: Thu May 31, 2007 10:23 am     Reply with quote

Hi All,
if any body know some think about this sensor please help me.
I read datasheet and wrote a routine but doesn,t work correctly
I,m appling Fclock about 4-5 MHz
but signal SO2 is coming early and I see 1 or 2 counted pixels.
This have to be 768 pixels.

Here is a routine for to count pixels;
Code:
void cp() {
   PixelCount=0;
   CK=1;SI=1;CK=0;SI=0;
   while(!SO) {
      CK=1;restart_wdt();
      CK=0;
      PixelCount++;
   }
   printf("Pixel: %lu\n",PixelCount);
   return;
}
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu May 31, 2007 11:48 am     Reply with quote

In order for a pin to be driven high you can't simply write a statement like 'CK=1'. You need to use input() or output() commands to change the state of an I/O.

Try:

Code:
void cp() {
   PixelCount=0;
   output_high(CK);
   output_high(SI);
   output_low(CK);
   output_low(SI);
   while(!SO) {
      output_high(CK);
      restart_wdt();
      output_low(CK);
      PixelCount++;
   }
   printf("Pixel: %lu\n",PixelCount);
   return;
}


I don't know anything about this sensor so I can't say this will talk to it properly. This is the proper way to manipulate an I/O unless you are using fast_io but that's another can of worms for somebody that's not very experienced.

Ronald
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Thu May 31, 2007 1:47 pm     Reply with quote

Code:
#byte PORTC      = 0xF82
#byte PORTB      = 0xF81
#byte PORTA      = 0xF80

#bit   DI    = PORTA.1
#bit   SO    = PORTB.2

#bit   SI    = PORTB.1
#bit   CK    = PORTB.0
.
.
.
   SET_TRIS_A(0b00111111);
   SET_TRIS_B(0b00000100);  // SO pin is input
   SET_TRIS_C(0b10000000);   // RX pin is input
   PORTA = 0;
   PORTB = 0;
   PORTC = 0;
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu May 31, 2007 4:42 pm     Reply with quote

You must also add the following if you want to use the set_tris option:

#use fast_io(a)
#use fast_io(b)
#use fast_io(c)

Ronald
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Sat Jun 02, 2007 3:54 pm     Reply with quote

ok, but it still doesn't work.

Last edited by tesla80 on Thu Jun 10, 2010 3:29 pm; edited 1 time in total
merakliev
Guest







PostPosted: Mon Jun 04, 2007 11:41 am     Reply with quote

a solution?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group