Ребят, подскажите где грабли. Не могу заставить ЦАП от Atiny13A работать. От Atmega8 без проблем, а с тинькой нефига.
Код:
/*
Chip type : ATiny13А
Program type : Application
AVR Core Clock frequency: 1,200000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : xxx
*****************************************************/
#include <tiny13a.h>
#include <delay.h>
#include <i2c.h>
#asm
.equ __i2c_port=0x18 //Адрес порта В
.equ __sda_bit=3
.equ __scl_bit=4
#endasm
#include <i2c.h>
unsigned int H_byte=0x8; //старший байт ЦАП
unsigned int L_byte=0x50;//младший байт ЦАП
void set_V()
{
// i2c программа******************************************************************
i2c_start(); //Кидаем команду "Cтарт" на шину I2C
i2c_write(0xC0); //Кидаем на шину адрес ЦАП
i2c_write(H_byte); // передача старшего байта данных
i2c_write(L_byte); // передача младшего байта данных
i2c_stop(); // стоп
}
void initMC(){
// Declare your local variables here
// Crystal Oscillator division factor: 8
#pragma optsize-
CLKPR=0x80;
CLKPR=0x03;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
// Input/Output Ports initialization
// Port B initialization
// Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0A output: Disconnected
// OC0B output: Disconnected
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;
// External Interrupt(s) initialization
// INT0: Off
// Interrupt on any change on pins PCINT0-5: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer/Counter 0 Interrupt(s) initialization
TIMSK0=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
ACSR=0x80;
ADCSRB=0x00;
DIDR0=0x00;
// ADC initialization
// ADC disabled
ADCSRA=0x00;
// I2C Bus initialization
// I2C Port: PORTB
// I2C SDA bit: 3
// I2C SCL bit: 4
// Bit Rate: 100 kHz
// Note: I2C settings are specified in the
// Project|Configure|C Compiler|Libraries|I2C menu.
i2c_init();
}
void main(void)
{
initMC();
set_V();
while (1){}
}


