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 CCS Technical Support

tea5767 help needed

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



Joined: 07 Jan 2005
Posts: 3

View user's profile Send private message

tea5767 help needed
PostPosted: Fri Jan 07, 2005 3:52 pm     Reply with quote

Hi all,

I need some help controlling a philips tea5767 chip. This is a fm radio ic that can be completely controlled by i2c. When writing to it everything seems to work. It seem to get ack's. so something seems to be listening. Because I don't get any audio signal from it, I want to read some data from this chip. Unfortunately the only thing I get back are zero's. So I'll post my code and hope anybody here got some insights/experience on this chip.

As a side note: the datasheet says bytes should be transmitted MSB first. Is this what the i2c_write function is doing?? It doesn't say in the help file.

bart

Code:

#include <16f877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP

#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7)
#use I2C(master, slow, sda=PIN_C1, scl=PIN_C2)




// radio stuff
void radioInit(void);
//void radioSearchUp(void);
//void radioSearchDown(void);
void radioStatus(void);


void main()
{
 SET_TRIS_B(0x00);
 OUTPUT_B(0x00);
 delay_ms(100);
 SET_TRIS_D(0x00);
 OUTPUT_D(0x00);

 printf("1.1\n\r");

 radioInit();
 
 
 while (1)
 {
 
  radioStatus();
 
  // heartbeat led on
  output_high(PIN_B4);
  //delay_ms(100);
   

  // heartbeat led off
  //output_low(PIN_B4);
  //delay_ms(100);

 }
}

radioInit()
{
 
 i2c_start();    // Start condition
 printf("\n\rstart");
 
 
 while(i2c_write(0xC0));// Device address
 printf("\n\raddress");
 while(i2c_write(0x1F));
 printf("\n\r byte1");
 while(i2c_write(0x7C));
 printf("\n\r byte2");
 while(i2c_write(0x30));
 printf("\n\r byte3");
 while(i2c_write(0x00));
 printf("\n\r byte4");
 while(i2c_write(0x00));
 printf("\n\r byte5");
 
 i2c_stop();     // Stop condition
 printf("\n\rstop");
 delay_ms(50);
 
}

radioStatus()
{
 int data;
 
 printf("\n\rR");

 i2c_start();    // Start condition
 i2c_write(0xC1);// Device address

 data = i2c_read();
 printf("\r\n%U", data);

 data = i2c_read();
 printf("\r\n%U", data);

 data = i2c_read();
 printf("\r\n%U", data);
 
 data = i2c_read();
 printf("\r\n%U", data);
 
 data = i2c_read();
 printf("\r\n%U", data);

 i2c_stop();     // Stop condition
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 07, 2005 4:08 pm     Reply with quote

The last call to i2c_read() before the i2c_stop() statement
must have a 0 parameter. Example:

i2c_read();
i2c_read();
i2c_read(0); // Last call does a NAK
bzuidgeest



Joined: 07 Jan 2005
Posts: 3

View user's profile Send private message

PostPosted: Sat Jan 08, 2005 8:35 am     Reply with quote

Ok I changed the last i2c_read() statement to i2c_read(0); But I'm still receiving only zero's back.
Ttelmah
Guest







PostPosted: Sat Jan 08, 2005 10:53 am     Reply with quote

Yes, the internal I2C, does send MSB first. This is 'standard' for I2C, and is shown in the chip's data sheet, if you look at the timing diagrams.
You could try waiting for the address to be acknowledged on the read, as you do on the write.

Best Wishes
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Sun Jan 09, 2005 1:16 am     Reply with quote

The code looks OK, although I haven't used this chip.
It looks like the writes were unsuccessful. First thing I would try is to remove all the printf
statements - instead, in the read operation save the bytes into an array and output them after the i2c_stop().

Some things to check:
1. Bus Enable pin set high for at least 10uS before write or read operation (or tied high permanently).

2. Bus Mode pin tied low to select i2c instead of 3-wire interface.

3. i2c bus pullups in the range 2k2 to 4k7.

4. If possible, check waveforms with an oscilloscope.

5. Test the write operation as follows:
Check that the SWP1 and SWP2 pins can be be set high and low by setting and clearing SWP1 (bit 0 of byte 3)
and SWP2 (bit 7 of byte 4) respectively. There needs to be 10k pullups on these pins as shown in the test schematic,
and SI (bit 0 of of byte 4) needs to be cleared for this to work.
If this works then the write operation was successful, and the read operation should work.
HTH
bzuidgeest



Joined: 07 Jan 2005
Posts: 3

View user's profile Send private message

PostPosted: Sun Jan 09, 2005 5:20 am     Reply with quote

Hi kenny,

I had not considered testing the way you subscribe in point 5. Exelent idea! I considered the writes to be working because the bytes i send get acknoledged. It's the reason there are while statements around all i2c_write statements. I will also follow up on Ttelmah's idea.

Hope it works,

bart
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