This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LM76 and ST7032 (correct)

Hi guys, i'm looking for a code to see the temperature capture from an LM76 in a ST7032 display... I'm newbie and now i know only how to write something on the ST032 ahah... But i definitely don't know how interface it with the LM76.
I'm working on C8051F020 with a chip (the drive where the LM76 and ST7032 are placed) link to the PORT 0

This is my starting code:

#include "C8051F020.H" //Device definitions

#define DISPLAY_ADDR    0x07C   //Display address
#define LINE1   0x000           //Line 1 address
#define LINE2   0x040           //Line 2 address

//Master Trasmitter
#define SMB_START       0x08
#define SMB_ADDR_ACK    0x018
#define SMB_DATA_ACK    0x028

I manage the display with this functions:

void init_display () {
        unsigned char dinit[] = {0x38, 0x39, 0x14, 0x74, 0x54, 0x6F, 0x0F, 0x01};
        screen_led = 1;
        i2c_out(DISPLAY_ADDR, dinit, sizeof(dinit));
}

void display_move_to (unsigned char addr) {
        unsigned char comm[] = {0x080, 0x000};
        comm[1] = addr | 0x080;
        i2c_out(DISPLAY_ADDR, comm, 2);
}

And this is the other functions:

sbit screen_led = P0^6;
sbit green_led = P1^6;

void init() {

        WDTCN = 0x0DE;  //le solite cose
        WDTCN = 0x0AD;
        OSCICN &= 0x014;

        EA = 1;

        /*******************
        i2c initalization
         *******************/

        XBR0 = 0x005;
        XBR1 = 0x000;
        XBR2 = 0x040;

        SMB0CN = 0x044;
        SMB0CR = 0x0B0;

        SCON0 |= 0x010;

        EIE1 |= 2;
        P1MDOUT |= 0x040;
        P0MDOUT |= 0x040;

        SI = 0;

}

char* i2c_data_out;
char i2c_addr_out;
unsigned char i2c_length_out;
unsigned char i2c_index_out;

void i2c_out(char addr, char* _data, unsigned char length) {

        while (i2c_index_out < i2c_length_out);

        STO = 1;
        STO = 0;

        i2c_length_out = length;
        i2c_index_out = 0;
        i2c_data_out = _data;
        i2c_addr_out = addr;

        STA = 1;        //starta

}
void i2c_status_interrupt () interrupt 7 {

        switch(SMB0STA) {

                case SMB_START:
                        STA = 0;
                        STO = 0;
                        SMB0DAT = (i2c_addr_out & 0x0FE);
                        SI = 0;
                        break;
                case SMB_ADDR_ACK:
                        SMB0DAT = i2c_data_out[0];
                        SI = 0;
                        break;
                case SMB_DATA_ACK:
                        i2c_index_out = i2c_index_out + 1;

                        if (i2c_index_out < i2c_length_out) {
                                SMB0DAT = i2c_data_out[i2c_index_out];
                        } else {
                                STO = 1;
                                STA = 0;
                        }
                        SI = 0;
                        break;
                default:
                        break;
        }
}

And finally, the main!:

void main() {
        init();
        green_led = 0;
        init_display();
        i2c_out(DISPLAY_ADDR, "@LINE1", 6);
        display_move_to(LINE2);
        i2c_out(DISPLAY_ADDR, "@LINE2", 6);
        while(1);
}

With this code i can write LINE1 and LINE2 in both display line

============================================================================================

This is the code i think can work to initialize LM76:

#define LM76_ADDR  0x48 //LM76 address

//Master Receiver
#define SMB_START_SENS 0x08
#define SMB_ADDR_ACK_SENS 0x40
#define SMB_DATA_ACK_SENS 0x50

But now i don't know how to proceed...

Any suggests? Thanks :D