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

PCF8574 can't get the interrupt

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



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PCF8574 can't get the interrupt
PostPosted: Sun Dec 19, 2004 3:05 am     Reply with quote

Okay, this is another question about the venerable PCF8574 I2C I/O expander.

My PCF8574 is running 6 buttons (each with a 4.7k pullup) and 2 LEDs (current source). Here's the code I use to initialize the PCF8574:

Code:


#define BUTTONS_ADDR    0x40                    // i2c write address of the PCF8574 i/o expander
#define I2CWRITE        0x00
#define I2CREAD         0x01

#define LED_TEMP        0x40
#define LED_CURRENT     0x80

#define BTN_TEMP        0x04
#define BTN_CURRENT     0x08
#define BTN_DEC         0x02
#define BTN_INC         0x01
#define BTN_CUT         0x10
#define BTN_ABLATE      0x20
#define BTN_ALL         0x3F


void i2c_init(int8 iAddr)
{
   int8 i;                                      // loop counter

   i = 0;
   do
   {
      i2c_start();
      ++i;
   }
   while (i < I2C_TIMEOUT && i2c_write(iAddr) == 1); // 0 returned for ACK

   if (i >= I2C_TIMEOUT)
   {
      coma();                                   // I2C bus timed out => disable the device
   }
}

// somewhere in the main...
   i2c_init(BUTTONS_ADDR | I2CWRITE);
   i2c_write(LED_TEMP | LED_CURRENT);
   i2c_stop();

   i2c_init(BUTTONS_ADDR | I2CWRITE);   
   i2c_write(BTN_ALL);                          // keep inputs as inputs
   i2c_stop();


After I run this INT# line remains low, when none of the buttons are pressed. What am I doing wrong?

Thanks,
Nick
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sun Dec 19, 2004 2:33 pm     Reply with quote

Here's additional info I gathered. If I want to use INT# line on the PCF8574, I have to make all i/o lines inputs. If I drive any of the i/o lines low I get the interrupt.

I have 2 choices:
1. Use PCA9554, which is pin-for-pin compatible with PCF8574. PCA9554 is truly bidirectional as opposed to quasi bidirectional PCF8574. Arrow carries them in all available packages except DIP. Does anyone know wehere to get PCA9554 in DIP?
2. Poll the buttons.

Nick
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Sun Dec 19, 2004 9:34 pm     Reply with quote

A venerable chip indeed, also second-sourced by TI these days.
You can use the PCF8574 for your particular application.

See pages 8 and 9 of the following for an explanation of why INT isn't asserted by a write:
http://focus.ti.com/lit/an/scpa032/scpa032.pdf

Do a read in the initialisation to clear any unhandled interrupt state, similar to the case when using the interrupt-on-change feature of portb on pics.
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