Gast
#85248
Hallo, ich versuche seit einigen Tagen erfolglos einen 16 Bit AD Wandler
aus dem Hause analog anzusprechen.
Ich programmiere in C mit Codevision. Mein Quellcode ist unten.
1. Vermutung: die Slave Adresse ist nicht richtig gesetzt. Laut
Datenblatt ist das 1001000. Aber auf ein i2c_write(adress) kommt kein
ack.
2. Vielleicht ist es auch ein Hardware Problem, der den ich habe hat
leider ein sehr kleines SMD Package, was ich mir zwar mit draht auf
einen 8 Pol IC sockel adaptiert habe, aber wer weiß ob da ein Problem
ist..ich kann mit dem Oszi kein rechteck auf scl feststellen. liegt das
direkt nach init an?
Pullup sind drin.
Fällt einem noch ein i2c 16Bit AD Wandler mit DIP gehäuse ein?
Code:
#include <mega16.h>
// I2C Bus functions
#asm
.equ __i2c_port=0x18
.equ __sda_bit=0
.equ __scl_bit=1
#endasm
#include <i2c.h>
// Standard Input/Output functions
#include <stdio.h>
#define adress 0b1001000
#define read 0b10111100
void main(void)
{
unsigned int help=0, data1, data2;
// Port B initialization
// Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In
Func7=In
// State0=T State1=T State2=T State3=T State4=T State5=T State6=T
State7=T
PORTB=0x00;
DDRB=0x00;
/
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x67;
// I2C Bus initialization
i2c_init();
while (1)
{
// Place your code here
help=i2c_start();
printf("\n\nStart1 = %u",help);
help = i2c_write(adress);
printf("\n\nadresse1 = %u",help);
help = i2c_write(read);
printf("\n\nregister = %u",help);
help=i2c_start();
printf("\n\nStart2 = %u",help);
help = i2c_write(adress);
printf("\n\nRead_adress = %u",help);
data1 = i2c_read(1);
data2 = i2c_read(0);
i2c_stop();
printf("\nData: %u %u",data1, data2);
};
}