Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ATmega32][C] Problem with communication with sensor SFH5712 by I2C

Status
Not open for further replies.

damiandoles

Newbie level 2
Joined
Jul 19, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Polnad
Activity points
1,315
Hello everybody :) I am working on engineering work and now I have big problem...I can't do nothing more without it. I'd like to connect with light ambient sensor OSRAM SFH5712, which communicate with ATmega32 by I2C bus, but there is low voltage - only 1,8V and 3,4 Mbit/s communication speed. Of course, this sensor can work with lowest frequency - 100kbit/s, 400kbit/s so I understand that it could be possible to connect with ATmega32 - for example with frequency 400kbit/s. In this case I understand that pull-ups resistor must be changed (560Ω for speed 3,4Mbit communication), but what resistor should be there for lowest frequency ? Next problem is low voltage, as I said. ATmega don't understand 1,8V - high level is when the voltage will be more that 2,5V, so I need logic converter - for example using transistors. I have attached some scheme, but It didn't work. Processor couldn't connect with sensor. Everythink what I did, it was made with datasheet (for software). Big problem is that, I bought 3 sensors, but now...I have the last one :-? I have destroyed two when I wanted unsolder it. This sensors are very small...about 2x2 milimiters. It is my last sensor and If I destroy it, I can't buy next because in my country I couldn't find shop with this sensor...I brought it from Germany. The library of TWI is working. I am really worried about it, what can I do with it :-? I hope that somebody will help me, I really thank you in advance for your help.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include "TWI.h"
#include "HD44780.h"
 
int main(void)
{
    LCD_Initialize();
    LCD_Clear();
    TWI_Init();
 
    unsigned char B, C;
    char tab1[8];
    char tab2[8];
    
    while(1)
    {
 
        //_delay_ms(5);
        TWI_Start();     
        TWI_Write(0x29); 
        TWI_Write(0x80);
        TWI_Write(0x03);
        //_delay_ms(300);
                            
        TWI_Start(); //repeated start
        //TWI_Write(0x29); 
        TWI_Write(0x8C);
        
        TWI_Start(); //repeated start
        B = TWI_Read(NACK);
        
        TWI_Start(); //repeated start
       // TWI_Write(0x29);
        TWI_Write(0x8D);
        
        TWI_Start(); //repeated start
        C = TWI_Read(NACK);
        
        TWI_Start(); //repeated start
        //TWI_Write(0x29);
        TWI_Write(0x80);
        TWI_Write(0x00);
        TWI_Stop();       
        //Hex(B,tab1);
        //Hex(C,tab2);
        
        //LCD_GoTo(1,0);
        //LCD_WriteText(tab2);
    }
}

 

Attachments

  • 2632358000_1344336864.png
    2632358000_1344336864.png
    43.4 KB · Views: 52

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top