<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=4&amp;t=11393&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-04-17T07:06:58+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=11393&amp;mode</id>
<entry>
<author><name><![CDATA[PITERK]]></name></author>
<updated>2015-04-17T07:06:58+01:00</updated>
<published>2015-04-17T07:06:58+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126739#p126739</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126739#p126739"/>
<title type="html"><![CDATA[Re: WinAVR problem przy kompilacji]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126739#p126739"><![CDATA[
Pewnie że tak. <br />Wywalasz uart- no chyba że będzie Ci jeszcze potrzebny. <br />Dodajesz obsługę LCD. <br />i zamiast <br />&quot; USART_Transmit(celsius);&quot;<br /><br />Wysyłasz na LCD zmienną celsius<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2913">PITERK</a> — 17 kwi 2015, o 07:06</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Raffaelloo]]></name></author>
<updated>2015-04-16T19:02:51+01:00</updated>
<published>2015-04-16T19:02:51+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126698#p126698</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126698#p126698"/>
<title type="html"><![CDATA[Re: WinAVR problem przy kompilacji]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126698#p126698"><![CDATA[
A teraz pytanie z innej beczki, nadaje się ten program, żeby go edytować i zrobić tylko pomiar i wyświetlanie tej temperatury na wyświetlaczu LCD 2x16 ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=9537">Raffaelloo</a> — 16 kwi 2015, o 19:02</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[janusz17]]></name></author>
<updated>2015-04-16T17:45:05+01:00</updated>
<published>2015-04-16T17:45:05+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126689#p126689</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126689#p126689"/>
<title type="html"><![CDATA[Re: WinAVR problem przy kompilacji]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126689#p126689"><![CDATA[
Widać w pliku makefile - linia 83, że nie ma dodanego pliku i2cmaster<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1226">janusz17</a> — 16 kwi 2015, o 17:45</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[PITERK]]></name></author>
<updated>2015-04-16T16:01:15+01:00</updated>
<published>2015-04-16T16:01:15+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126681#p126681</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126681#p126681"/>
<title type="html"><![CDATA[Re: WinAVR problem przy kompilacji]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126681#p126681"><![CDATA[
Utworzyłem projekt w AS6 na ustawieniach make domyślnych i się udało bez problemu. <br />Build succeeded.<br />========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========<br /><br />Wydaje mi się że nie może ci odnaleźć pliku z roz *.h. <br />Podłącz go jeszcze raz.<br /><br />W załączniku masz stworzony projekt. Zobacz jak to wygląda.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2913">PITERK</a> — 16 kwi 2015, o 16:01</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Raffaelloo]]></name></author>
<updated>2015-04-16T14:07:50+01:00</updated>
<published>2015-04-16T14:07:50+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126670#p126670</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126670#p126670"/>
<title type="html"><![CDATA[Re: WinAVR problem przy kompilacji]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126670#p126670"><![CDATA[
<!-- m --><a class="postlink" href="http://www.dexterindustries.com/howto/working-with-avr/atmega48-and-the-mlx90614/" >http://www.dexterindustries.com/howto/w ... -mlx90614/</a><!-- m --><br />Plik *.c<br />[syntax=c]//<br />// Atmega48P<br />// Copyright 2011 Dexter Industries.  http://www.dexterindustries.com/howto<br />// Chip:            Atmega48P<br />// Operations:      This chip reads the MLX90614 temperature sensor, calculates out the temperature value, and sends it out<br />//                  on the serial line.  <br />// <br />//                  Important to note two critical changes that must be made to adapt to other chips:<br />//                      In i2cmaster.S:<br />//                              - Match the pin and ports at the top.   This example matches to PIN B 1, PIN B 2.  <br />//                              - Match the i2c_delay_T2 to the clock.  This example matches to 16 Mhz. <br />//                                  http://www.avr-asm-tutorial.net/avr_en/beginner/JUMP.html<br />// <br />//                  Sensor Notes:  needs at least a 2.2k resistor.  Max operation is 100 kHz.<br />//                  Based on the I2C Bitbang protocol built by Fleury.  http://jump.to/fleury<br />// <br />// Created: 4/21/2011 <br />// Author: John<br />// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation.<br />// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br />// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br />// <br /> <br />#define F_CPU 16000000UL            // Clock speed for UART // We're using an external 16MHz Clock<br />#define FOSC 16000000UL             // Clock Speed for UART // We're using an external 16MHz Clock<br />#define BAUD 9600<br />#define MYUBRR FOSC/16/BAUD-1<br /> <br />#define SCL_CLOCK  100000L          // JDC added.<br /> <br />#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &quot;i2cmaster.h&quot;<br /> <br />char ret1 = 0;<br />char ret2 = 0;<br />char ret3 = 0;<br /> <br />long celsius = 0;<br /> <br />///////////////////////////////////////////////////////////////////////////////////////////////<br />///////////////////////////////////////////////////////////////////////////////////////////////<br /> <br />// Initializes USART.<br />// Very well.<br />void USART_Init( unsigned int ubrr)<br />{<br />    /*Set baud rate */<br />    UBRR0H = (unsigned char)(ubrr&gt;&gt;8);<br />    UBRR0L = (unsigned char)ubrr;<br />    /*Enable receiver and transmitter */<br />    UCSR0B = (1&lt;&lt;RXEN0)|(1&lt;&lt;TXEN0);<br />    /* Set frame format: 8data, 2stop bit */<br />    UCSR0C = (1&lt;&lt;USBS0)|(3&lt;&lt;UCSZ00);<br />}<br /> <br />// TRANSMIT<br />// This code sends an integer over the line.<br />void USART_Transmit(int data)<br />{<br />    // If you look in the data sheet, there is not any register named UCSRnB. <br />    // The little 'n' means that you substitue that with a number for the exact <br />    // register that you want to use such as UCSR0B or UCSR1B.<br />    /* Wait for empty transmit buffer */<br />    while ( !(UCSR0A &amp; (1&lt;&lt;UDRE0)));      // Using register 0<br /> <br />    /* Put data into buffer, sends the data */<br />    UDR0 = data;                            // Using register 0<br />}<br /> <br />// WAIT:  Take a breather.<br />void Wait()<br />{<br />   uint8_t i=0;<br />   for(;i&lt;5;i++)<br />    _delay_ms(10);<br />      //_delay_loop_1(0);<br />}<br /> <br />// BLINK This will serve as a debugging tool<br />// just to let us know we're still alive.<br />void blink_on(){<br />        //Set PC0=High(+5v)<br />        PORTC|=0b00111111;<br />        Wait();<br />}<br /> <br />void blink_off(){<br />        //Set PC0=Low(GND)<br />        PORTC&amp;=0b11000000;<br />        Wait();<br />}<br /> <br />void blink(){<br />    blink_on();<br />    blink_off();<br />}<br /> <br /> <br />void i2c_refresh(){<br />              <br />         int i2c_slave_address =  0x5A&lt;&lt;1;                    // Shifted address.  0x5A is the address, shifted is B4.<br />              <br />         i2c_start(i2c_slave_address+I2C_WRITE);            // Set device address and read mode      <br />         i2c_write(0x07);                                   // Read the temp.  0x06 = ambient Temp.  0x07 = TObj1, 0x08 = TObj2.<br />          <br />         i2c_rep_start(i2c_slave_address+I2C_READ);         // Kick it.<br />         ret1 = i2c_readAck();                              // Read the first bit.<br />         ret2 = i2c_readAck();                              // Read the second bit.<br />         ret3 = i2c_readNak();                              // This is a NACK because it's the last byte.  We don't care much about this.  <br />         i2c_stop();<br />          <br />         // Process the data.<br />          <br />        double tempFactor = 0.02;   // 0.02 degrees per bit<br />        double tempData = 0x0000;   // zero out the data<br />        int frac;                   // data past the decimal point<br />   <br />        // This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.<br />        tempData = (double)(((ret2 &amp; 0x007F) &lt;&lt; 8) + ret1);<br />        tempData = (tempData * tempFactor)-0.01;<br />   <br />        celsius = ((tempData - 273.15)*100);        // Final value of celsius is multipled by 100 so we don't have decimals.<br /> <br /> <br />}<br />///////////////////////////////////////////////////////////////////////////////////////////////<br />///////////////////////////////////////////////////////////////////////////////////////////////<br /> <br />int main(void)<br />{<br /> <br />    i2c_init();                 // Initialize I2C library   <br />    USART_Init(MYUBRR);         // Initialize USART<br />     <br />    while(1)<br />    {<br />        USART_Transmit(0xFF);       // Just markers for the serial stream.<br />        USART_Transmit(celsius);    // Transmit the value of celsius.<br />        i2c_refresh();              // Refresh the data from the MLX90614<br />        blink();                    // Blink to let us know the microcontroller is alive<br />    }<br />}[/syntax]<br />Plik *.h<br />[syntax=c]#ifndef _I2CMASTER_H<br />#define _I2CMASTER_H   1<br />/************************************************************************* <br />* Title:    C include file for the I2C master interface <br />*           (i2cmaster.S or twimaster.c)<br />* Author:   Peter Fleury &lt;pfleury@gmx.ch&gt;  http://jump.to/fleury<br />* File:     $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $<br />* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3<br />* Target:   any AVR device<br />* Usage:    see Doxygen manual<br />**************************************************************************/<br /> <br />#ifdef DOXYGEN<br />/**<br /> @defgroup pfleury_ic2master I2C Master library<br /> @code #include &lt;i2cmaster.h&gt; @endcode<br />   <br /> @brief I2C (TWI) Master Software Library<br /> <br /> Basic routines for communicating with I2C slave devices. This single master <br /> implementation is limited to one bus master on the I2C bus. <br /> <br /> This I2c library is implemented as a compact assembler software implementation of the I2C protocol <br /> which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c).<br /> Since the API for these two implementations is exactly the same, an application can be linked either against the<br /> software I2C implementation or the hardware I2C implementation.<br /> <br /> Use 4.7k pull-up resistor on the SDA and SCL pin.<br />  <br /> Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module <br /> i2cmaster.S to your target when using the software I2C implementation ! <br />  <br /> Adjust the  CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion.<br /> <br /> @note <br />    The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted <br />    to GNU assembler and AVR-GCC C call interface.<br />    Replaced the incorrect quarter period delays found in AVR300 with <br />    half period delays. <br />     <br /> @author Peter Fleury pfleury@gmx.ch  http://jump.to/fleury<br /> <br /> @par API Usage Example<br />  The following code shows typical usage of this library, see example test_i2cmaster.c<br /> <br /> @code<br /> <br /> #include &lt;i2cmaster.h&gt;<br /> <br /> <br /> #define Dev24C02  0xA2      // device address of EEPROM 24C02, see datasheet<br /> <br /> int main(void)<br /> {<br />     unsigned char ret;<br /> <br />     i2c_init();                             // initialize I2C library<br /> <br />     // write 0x75 to EEPROM address 5 (Byte Write) <br />     i2c_start_wait(Dev24C02+I2C_WRITE);     // set device address and write mode<br />     i2c_write(0x05);                        // write address = 5<br />     i2c_write(0x75);                        // write value 0x75 to EEPROM<br />     i2c_stop();                             // set stop conditon = release bus<br /> <br /> <br />     // read previously written value back from EEPROM address 5 <br />     i2c_start_wait(Dev24C02+I2C_WRITE);     // set device address and write mode<br /> <br />     i2c_write(0x05);                        // write address = 5<br />     i2c_rep_start(Dev24C02+I2C_READ);       // set device address and read mode<br /> <br />     ret = i2c_readNak();                    // read one byte from EEPROM<br />     i2c_stop();<br /> <br />     for(;;);<br /> }<br /> @endcode<br /> <br />*/<br />#endif /* DOXYGEN */<br /> <br />/**@{*/<br /> <br />#if (__GNUC__ * 100 + __GNUC_MINOR__) &lt; 304<br />#error &quot;This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !&quot;<br />#endif<br /> <br />#include &lt;avr/io.h&gt;<br /> <br />/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */<br />#define I2C_READ    1<br /> <br />/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */<br />#define I2C_WRITE   0<br /> <br /> <br />/**<br /> @brief initialize the I2C master interace. Need to be called only once <br /> @param  void<br /> @return none<br /> */<br />extern void i2c_init(void);<br /> <br /> <br />/** <br /> @brief Terminates the data transfer and releases the I2C bus <br /> @param void<br /> @return none<br /> */<br />extern void i2c_stop(void);<br /> <br /> <br />/** <br /> @brief Issues a start condition and sends address and transfer direction <br />   <br /> @param    addr address and transfer direction of I2C device<br /> @retval   0   device accessible <br /> @retval   1   failed to access device <br /> */<br />extern unsigned char i2c_start(unsigned char addr);<br /> <br /> <br />/**<br /> @brief Issues a repeated start condition and sends address and transfer direction <br /> <br /> @param   addr address and transfer direction of I2C device<br /> @retval  0 device accessible<br /> @retval  1 failed to access device<br /> */<br />extern unsigned char i2c_rep_start(unsigned char addr);<br /> <br /> <br />/**<br /> @brief Issues a start condition and sends address and transfer direction <br />    <br /> If device is busy, use ack polling to wait until device ready <br /> @param    addr address and transfer direction of I2C device<br /> @return   none<br /> */<br />extern void i2c_start_wait(unsigned char addr);<br /> <br />  <br />/**<br /> @brief Send one byte to I2C device<br /> @param    data  byte to be transfered<br /> @retval   0 write successful<br /> @retval   1 write failed<br /> */<br />extern unsigned char i2c_write(unsigned char data);<br /> <br /> <br />/**<br /> @brief    read one byte from the I2C device, request more data from device <br /> @return   byte read from I2C device<br /> */<br />extern unsigned char i2c_readAck(void);<br /> <br />/**<br /> @brief    read one byte from the I2C device, read is followed by a stop condition <br /> @return   byte read from I2C device<br /> */<br />extern unsigned char i2c_readNak(void);<br /> <br />/** <br /> @brief    read one byte from the I2C device<br />  <br /> Implemented as a macro, which calls either i2c_readAck or i2c_readNak<br />  <br /> @param    ack 1 send ack, request more data from device&lt;br&gt;<br />               0 send nak, read is followed by a stop condition <br /> @return   byte read from I2C device<br /> */<br />extern unsigned char i2c_read(unsigned char ack);<br />#define i2c_read(ack)  (ack) ? i2c_readAck() : i2c_readNak(); <br /> <br /> <br />/**@}*/<br />#endif[/syntax]<br />Plik *.S<br />[syntax=asm];*************************************************************************<br />; Title :    I2C (Single) Master Implementation<br />; Author:    Peter Fleury &lt;pfleury@gmx.ch&gt;  http://jump.to/fleury<br />;            based on Atmel Appl. Note AVR300<br />; File:      $Id: i2cmaster.S,v 1.12 2008/03/02 08:51:27 peter Exp $<br />; Software:  AVR-GCC 3.3 or higher<br />; Target:    any AVR device<br />;<br />; DESCRIPTION<br />;   Basic routines for communicating with I2C slave devices. This<br />;   &quot;single&quot; master implementation is limited to one bus master on the<br />;   I2C bus. <br />;  <br />;       Based on the Atmel Application Note AVR300, corrected and adapted <br />;       to GNU assembler and AVR-GCC C call interface<br />;       Replaced the incorrect quarter period delays found in AVR300 with <br />;       half period delays. <br />;<br />; USAGE<br />;   These routines can be called from C, refere to file i2cmaster.h.<br />;       See example test_i2cmaster.c <br />;   Adapt the SCL and SDA port and pin definitions and eventually <br />;   the delay routine to your target !<br />;   Use 4.7k pull-up resistor on the SDA and SCL pin.<br />;<br />; NOTES<br />;   The I2C routines can be called either from non-interrupt or<br />;   interrupt routines, not both.<br />;<br />;*************************************************************************<br /> <br />#if (__GNUC__ * 100 + __GNUC_MINOR__) &lt; 303<br />#error &quot;This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !&quot;<br />#endif<br /> <br /> <br />#include &lt;avr/io.h&gt;<br /> <br /> <br /> <br />;***** Adapt these SCA and SCL port and pin definition to your target !!<br />;<br />#define SDA             1               //  Changed by Dexter Industries<br />#define SCL             2               //  Changed by Dexter Industries<br />#define SDA_PORT        PORTB           //  Changed by Dexter Industries<br />#define SCL_PORT        PORTB           //  Changed by Dexter Industries<br /> <br />;******<br /> <br />;-- map the IO register back into the IO address space<br />#define SDA_DDR     (_SFR_IO_ADDR(SDA_PORT) - 1)<br />#define SCL_DDR     (_SFR_IO_ADDR(SCL_PORT) - 1)<br />#define SDA_OUT     _SFR_IO_ADDR(SDA_PORT)<br />#define SCL_OUT     _SFR_IO_ADDR(SCL_PORT)<br />#define SDA_IN      (_SFR_IO_ADDR(SDA_PORT) - 2)<br />#define SCL_IN      (_SFR_IO_ADDR(SCL_PORT) - 2)<br /> <br /> <br />#ifndef __tmp_reg__<br />#define __tmp_reg__ 0<br />#endif<br /> <br /> <br />    .section .text<br /> <br />;*************************************************************************<br />; delay half period<br />; For I2C in normal mode (100kHz), use T/2 &gt; 5us<br />; For I2C in fast mode (400kHz),   use T/2 &gt; 1.3us<br />;*************************************************************************<br />    .stabs  &quot;&quot;,100,0,0,i2c_delay_T2<br />    .stabs  &quot;i2cmaster.S&quot;,100,0,0,i2c_delay_T2<br />    .func i2c_delay_T2  ; delay 5.0 microsec with 4 Mhz crystal <br />i2c_delay_T2:    ; 4 cycles<br />    ; a nop delays 1 count.<br />    ; you have to align this up to the clock speed of the processor.<br />    ; To get 5.0 microseconds with a 16 Mhz crystal, you have to <br />    ; have 80 count delays.  Without this, it won't work.  <br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (5)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (10)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (15)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (20)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (25)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (30)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (35)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (40)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (45)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (50)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (55)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (60)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (65)<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count<br />    nop ; deleays 1 count (70)<br /> <br />    nop          ; 1<br />    nop          ; 1   &quot;<br />    nop          ; 1   &quot;<br />    ret          ; 3   &quot;<br />    .endfunc     ; total of 80 cycles = 5.0 microsec with 16 MHZ crystal<br />                 ; total 20 cyles = 5.0 microsec with 4 Mhz crystal <br /> <br /> <br />;*************************************************************************<br />; Initialization of the I2C bus interface. Need to be called only once<br />; <br />; extern void i2c_init(void)<br />;*************************************************************************<br />    .global i2c_init<br />    .func i2c_init<br />i2c_init:<br />    cbi SDA_DDR,SDA     ;release SDA<br />    cbi SCL_DDR,SCL     ;release SCL<br />    cbi SDA_OUT,SDA<br />    cbi SCL_OUT,SCL<br />    ret<br />    .endfunc<br /> <br /> <br />;*************************************************************************  <br />; Issues a start condition and sends address and transfer direction.<br />; return 0 = device accessible, 1= failed to access device<br />;<br />; extern unsigned char i2c_start(unsigned char addr);<br />;   addr = r24, return = r25(=0):r24<br />;*************************************************************************<br /> <br />    .global i2c_start<br />    .func   i2c_start<br />i2c_start:<br />    sbi     SDA_DDR,SDA ;force SDA low<br />    rcall   i2c_delay_T2    ;delay T/2<br />     <br />    rcall   i2c_write   ;write address<br />    ret<br />    .endfunc        <br /> <br /> <br />;*************************************************************************<br />; Issues a repeated start condition and sends address and transfer direction.<br />; return 0 = device accessible, 1= failed to access device<br />;<br />; extern unsigned char i2c_rep_start(unsigned char addr);<br />;   addr = r24,  return = r25(=0):r24<br />;*************************************************************************<br /> <br />    .global i2c_rep_start<br />    .func   i2c_rep_start<br />i2c_rep_start:<br />    sbi SCL_DDR,SCL ;force SCL low<br />    rcall   i2c_delay_T2    ;delay  T/2<br />    cbi SDA_DDR,SDA ;release SDA<br />    rcall   i2c_delay_T2    ;delay T/2<br />    cbi SCL_DDR,SCL ;release SCL<br />    rcall   i2c_delay_T2    ;delay  T/2<br />    sbi     SDA_DDR,SDA ;force SDA low<br />    rcall   i2c_delay_T2    ;delay  T/2<br />     <br />    rcall   i2c_write   ;write address<br />    ret<br />    .endfunc<br /> <br /> <br />;*************************************************************************  <br />; Issues a start condition and sends address and transfer direction.<br />; If device is busy, use ack polling to wait until device is ready<br />;<br />; extern void i2c_start_wait(unsigned char addr);<br />;   addr = r24<br />;*************************************************************************<br /> <br />    .global i2c_start_wait<br />    .func   i2c_start_wait<br />i2c_start_wait:<br />    mov __tmp_reg__,r24<br />i2c_start_wait1:<br />    sbi     SDA_DDR,SDA ;force SDA low<br />    rcall   i2c_delay_T2    ;delay T/2<br />    mov r24,__tmp_reg__<br />    rcall   i2c_write   ;write address<br />    tst r24     ;if device not busy -&gt; done<br />    breq    i2c_start_wait_done<br />    rcall   i2c_stop    ;terminate write operation<br />    rjmp    i2c_start_wait1 ;device busy, poll ack again<br />i2c_start_wait_done:<br />    ret<br />    .endfunc    <br /> <br /> <br />;*************************************************************************<br />; Terminates the data transfer and releases the I2C bus<br />;<br />; extern void i2c_stop(void)<br />;*************************************************************************<br /> <br />    .global i2c_stop<br />    .func   i2c_stop<br />i2c_stop:<br />    sbi SCL_DDR,SCL ;force SCL low<br />    sbi SDA_DDR,SDA ;force SDA low<br />    rcall   i2c_delay_T2    ;delay T/2<br />    cbi SCL_DDR,SCL ;release SCL<br />    rcall   i2c_delay_T2    ;delay T/2<br />    cbi SDA_DDR,SDA ;release SDA<br />    rcall   i2c_delay_T2    ;delay T/2<br />    ret<br />    .endfunc<br /> <br /> <br />;*************************************************************************<br />; Send one byte to I2C device<br />; return 0 = write successful, 1 = write failed<br />;<br />; extern unsigned char i2c_write( unsigned char data );<br />;   data = r24,  return = r25(=0):r24<br />;*************************************************************************<br />    .global i2c_write<br />    .func   i2c_write<br />i2c_write:<br />    sec         ;set carry flag<br />    rol     r24     ;shift in carry and out bit one<br />    rjmp    i2c_write_first<br />i2c_write_bit:<br />    lsl r24     ;if transmit register empty<br />i2c_write_first:<br />    breq    i2c_get_ack<br />    sbi SCL_DDR,SCL ;force SCL low<br />    brcc    i2c_write_low<br />    nop<br />    cbi SDA_DDR,SDA ;release SDA<br />    rjmp    i2c_write_high<br />i2c_write_low:<br />    sbi SDA_DDR,SDA ;force SDA low<br />    rjmp    i2c_write_high<br />i2c_write_high:<br />    rcall   i2c_delay_T2    ;delay T/2<br />    cbi SCL_DDR,SCL ;release SCL<br />    rcall   i2c_delay_T2    ;delay T/2<br />    rjmp    i2c_write_bit<br />     <br />i2c_get_ack:<br />    sbi SCL_DDR,SCL ;force SCL low<br />    cbi SDA_DDR,SDA ;release SDA<br />    rcall   i2c_delay_T2    ;delay T/2<br />    cbi SCL_DDR,SCL ;release SCL<br />i2c_ack_wait:<br />    sbis    SCL_IN,SCL  ;wait SCL high (in case wait states are inserted)<br />    rjmp    i2c_ack_wait<br />     <br />    clr r24     ;return 0<br />    sbic    SDA_IN,SDA  ;if SDA high -&gt; return 1<br />    ldi r24,1<br />    rcall   i2c_delay_T2    ;delay T/2<br />    clr r25<br />    ret<br />    .endfunc<br /> <br /> <br /> <br />;*************************************************************************<br />; read one byte from the I2C device, send ack or nak to device<br />; (ack=1, send ack, request more data from device <br />;  ack=0, send nak, read is followed by a stop condition)<br />;<br />; extern unsigned char i2c_read(unsigned char ack);<br />;   ack = r24, return = r25(=0):r24<br />; extern unsigned char i2c_readAck(void);<br />; extern unsigned char i2c_readNak(void);<br />;   return = r25(=0):r24<br />;*************************************************************************<br />    .global i2c_readAck<br />    .global i2c_readNak<br />    .global i2c_read        <br />    .func   i2c_read<br />i2c_readNak:<br />    clr r24<br />    rjmp    i2c_read<br />i2c_readAck:<br />    ldi r24,0x01<br />i2c_read:<br />    ldi r23,0x01    ;data = 0x01<br />i2c_read_bit:<br />    sbi SCL_DDR,SCL ;force SCL low<br />    cbi SDA_DDR,SDA ;release SDA (from previous ACK)<br />    rcall   i2c_delay_T2    ;delay T/2<br />     <br />    cbi SCL_DDR,SCL ;release SCL<br />    rcall   i2c_delay_T2    ;delay T/2<br />     <br />i2c_read_stretch:<br />    sbis SCL_IN, SCL        ;loop until SCL is high (allow slave to stretch SCL)<br />    rjmp    i2c_read_stretch<br />         <br />    clc         ;clear carry flag<br />    sbic    SDA_IN,SDA  ;if SDA is high<br />    sec         ;  set carry flag<br />     <br />    rol r23     ;store bit<br />    brcc    i2c_read_bit    ;while receive register not full<br />     <br />i2c_put_ack:<br />    sbi SCL_DDR,SCL ;force SCL low  <br />    cpi r24,1<br />    breq    i2c_put_ack_low ;if (ack=0)<br />    cbi SDA_DDR,SDA ;      release SDA<br />    rjmp    i2c_put_ack_high<br />i2c_put_ack_low:                ;else<br />    sbi SDA_DDR,SDA ;      force SDA low<br />i2c_put_ack_high:<br />    rcall   i2c_delay_T2    ;delay T/2<br />    cbi SCL_DDR,SCL ;release SCL<br />i2c_put_ack_wait:<br />    sbis    SCL_IN,SCL  ;wait SCL high<br />    rjmp    i2c_put_ack_wait<br />    rcall   i2c_delay_T2    ;delay T/2<br />    mov r24,r23<br />    clr r25<br />    ret<br />    .endfunc[/syntax]<br />Plik Makefile:<br />[syntax=c]# Hey Emacs, this is a -*- makefile -*-<br />#----------------------------------------------------------------------------<br /># WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.<br />#<br /># Released to the Public Domain<br />#<br /># Additional material for this makefile was written by:<br /># Peter Fleury<br /># Tim Henigan<br /># Colin O'Flynn<br /># Reiner Patommel<br /># Markus Pfaff<br /># Sander Pool<br /># Frederik Rouleau<br /># Carlos Lamas<br />#<br />#----------------------------------------------------------------------------<br /># On command line:<br />#<br /># make all = Make software.<br />#<br /># make clean = Clean out built project files.<br />#<br /># make coff = Convert ELF to AVR COFF.<br />#<br /># make extcoff = Convert ELF to AVR Extended COFF.<br />#<br /># make program = Download the hex file to the device, using avrdude.<br />#                Please customize the avrdude settings below first!<br />#<br /># make debug = Start either simulavr or avarice as specified for debugging, <br />#              with avr-gdb or avr-insight as the front end for debugging.<br />#<br /># make filename.s = Just compile filename.c into the assembler code only.<br />#<br /># make filename.i = Create a preprocessed source file for use in submitting<br />#                   bug reports to the GCC project.<br />#<br /># To rebuild project do &quot;make clean&quot; then &quot;make all&quot;.<br />#----------------------------------------------------------------------------<br /><br /><br /># MCU name<br />MCU = atmega48p<br /><br /><br /># Processor frequency.<br />#     This will define a symbol, F_CPU, in all source code files equal to the <br />#     processor frequency. You can then use this symbol in your source code to <br />#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done<br />#     automatically to create a 32-bit value in your source code.<br />#     Typical values are:<br />#         F_CPU =  1000000<br />#         F_CPU =  1843200<br />#         F_CPU =  2000000<br />#         F_CPU =  3686400<br />#         F_CPU =  4000000<br />#         F_CPU =  7372800<br />#         F_CPU =  8000000<br />#         F_CPU = 11059200<br />#         F_CPU = 14745600<br />#         F_CPU = 16000000<br />#         F_CPU = 18432000<br />#         F_CPU = 20000000<br />F_CPU = 16000000<br /><br /><br /># Output format. (can be srec, ihex, binary)<br />FORMAT = ihex<br /><br /><br /># Target file name (without extension).<br />TARGET = Atmega48PandMLX90614<br /><br /><br /># Object files directory<br />#     To put object files in current directory, use a dot (.), do NOT make<br />#     this an empty or blank macro!<br />OBJDIR = .<br /><br /><br /># List C source files here. (C dependencies are automatically generated.)<br />SRC = $(TARGET).c<br /><br /><br /># List C++ source files here. (C dependencies are automatically generated.)<br />CPPSRC = <br /><br /><br /># List Assembler source files here.<br />#     Make them always end in a capital .S.  Files ending in a lowercase .s<br />#     will not be considered source files but generated files (assembler<br />#     output from the compiler), and will be deleted upon &quot;make clean&quot;!<br />#     Even though the DOS/Win* filesystem matches both .s and .S the same,<br />#     it will preserve the spelling of the filenames, and gcc itself does<br />#     care about how the name is spelled on its command-line.<br />ASRC =<br /><br /><br /># Optimization level, can be &#91;0, 1, 2, 3, s&#93;. <br />#     0 = turn off optimization. s = optimize for size.<br />#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)<br />OPT = s<br /><br /><br /># Debugging format.<br />#     Native formats for AVR-GCC's -g are dwarf-2 &#91;default&#93; or stabs.<br />#     AVR Studio 4.10 requires dwarf-2.<br />#     AVR &#91;Extended&#93; COFF format requires stabs, plus an avr-objcopy run.<br />DEBUG = dwarf-2<br /><br /><br /># List any extra directories to look for include files here.<br />#     Each directory must be seperated by a space.<br />#     Use forward slashes for directory separators.<br />#     For a directory that has spaces, enclose it in quotes.<br />EXTRAINCDIRS = <br /><br /><br /># Compiler flag to set the C Standard level.<br />#     c89   = &quot;ANSI&quot; C<br />#     gnu89 = c89 plus GCC extensions<br />#     c99   = ISO C99 standard (not yet fully implemented)<br />#     gnu99 = c99 plus GCC extensions<br />CSTANDARD = -std=gnu99<br /><br /><br /># Place -D or -U options here for C sources<br />CDEFS = -DF_CPU=$(F_CPU)UL<br /><br /><br /># Place -D or -U options here for ASM sources<br />ADEFS = -DF_CPU=$(F_CPU)<br /><br /><br /># Place -D or -U options here for C++ sources<br />CPPDEFS = -DF_CPU=$(F_CPU)UL<br />#CPPDEFS += -D__STDC_LIMIT_MACROS<br />#CPPDEFS += -D__STDC_CONSTANT_MACROS<br /><br /><br /><br />#---------------- Compiler Options C ----------------<br />#  -g*:          generate debugging information<br />#  -O*:          optimization level<br />#  -f...:        tuning, see GCC manual and avr-libc documentation<br />#  -Wall...:     warning level<br />#  -Wa,...:      tell GCC to pass this to the assembler.<br />#    -adhlns...: create assembler listing<br />CFLAGS = -g$(DEBUG)<br />CFLAGS += $(CDEFS)<br />CFLAGS += -O$(OPT)<br />CFLAGS += -funsigned-char<br />CFLAGS += -funsigned-bitfields<br />CFLAGS += -fpack-struct<br />CFLAGS += -fshort-enums<br />CFLAGS += -Wall<br />CFLAGS += -Wstrict-prototypes<br />#CFLAGS += -mshort-calls<br />#CFLAGS += -fno-unit-at-a-time<br />#CFLAGS += -Wundef<br />#CFLAGS += -Wunreachable-code<br />#CFLAGS += -Wsign-compare<br />CFLAGS += -Wa,-adhlns=$(&lt;:%.c=$(OBJDIR)/%.lst)<br />CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))<br />CFLAGS += $(CSTANDARD)<br /><br /><br />#---------------- Compiler Options C++ ----------------<br />#  -g*:          generate debugging information<br />#  -O*:          optimization level<br />#  -f...:        tuning, see GCC manual and avr-libc documentation<br />#  -Wall...:     warning level<br />#  -Wa,...:      tell GCC to pass this to the assembler.<br />#    -adhlns...: create assembler listing<br />CPPFLAGS = -g$(DEBUG)<br />CPPFLAGS += $(CPPDEFS)<br />CPPFLAGS += -O$(OPT)<br />CPPFLAGS += -funsigned-char<br />CPPFLAGS += -funsigned-bitfields<br />CPPFLAGS += -fpack-struct<br />CPPFLAGS += -fshort-enums<br />CPPFLAGS += -fno-exceptions<br />CPPFLAGS += -Wall<br />CPPFLAGS += -Wundef<br />#CPPFLAGS += -mshort-calls<br />#CPPFLAGS += -fno-unit-at-a-time<br />#CPPFLAGS += -Wstrict-prototypes<br />#CPPFLAGS += -Wunreachable-code<br />#CPPFLAGS += -Wsign-compare<br />CPPFLAGS += -Wa,-adhlns=$(&lt;:%.cpp=$(OBJDIR)/%.lst)<br />CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))<br />#CPPFLAGS += $(CSTANDARD)<br /><br /><br />#---------------- Assembler Options ----------------<br />#  -Wa,...:   tell GCC to pass this to the assembler.<br />#  -adhlns:   create listing<br />#  -gstabs:   have the assembler create line number information; note that<br />#             for use in COFF files, additional information about filenames<br />#             and function names needs to be present in the assembler source<br />#             files -- see avr-libc docs &#91;FIXME: not yet described there&#93;<br />#  -listing-cont-lines: Sets the maximum number of continuation lines of hex <br />#       dump that will be displayed for a given single line of source input.<br />ASFLAGS = $(ADEFS) -Wa,-adhlns=$(&lt;:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100<br /><br /><br />#---------------- Library Options ----------------<br /># Minimalistic printf version<br />PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min<br /><br /># Floating point printf version (requires MATH_LIB = -lm below)<br />PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt<br /><br /># If this is left blank, then it will use the Standard printf version.<br />PRINTF_LIB = <br />#PRINTF_LIB = $(PRINTF_LIB_MIN)<br />#PRINTF_LIB = $(PRINTF_LIB_FLOAT)<br /><br /><br /># Minimalistic scanf version<br />SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min<br /><br /># Floating point + %&#91; scanf version (requires MATH_LIB = -lm below)<br />SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt<br /><br /># If this is left blank, then it will use the Standard scanf version.<br />SCANF_LIB = <br />#SCANF_LIB = $(SCANF_LIB_MIN)<br />#SCANF_LIB = $(SCANF_LIB_FLOAT)<br /><br /><br />MATH_LIB = -lm<br /><br /><br /># List any extra directories to look for libraries here.<br />#     Each directory must be seperated by a space.<br />#     Use forward slashes for directory separators.<br />#     For a directory that has spaces, enclose it in quotes.<br />EXTRALIBDIRS = <br /><br /><br /><br />#---------------- External Memory Options ----------------<br /><br /># 64 KB of external RAM, starting after internal RAM (ATmega128!),<br /># used for variables (.data/.bss) and heap (malloc()).<br />#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff<br /><br /># 64 KB of external RAM, starting after internal RAM (ATmega128!),<br /># only used for heap (malloc()).<br />#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff<br /><br />EXTMEMOPTS =<br /><br /><br /><br />#---------------- Linker Options ----------------<br />#  -Wl,...:     tell GCC to pass this to linker.<br />#    -Map:      create map file<br />#    --cref:    add cross reference to  map file<br />LDFLAGS = -Wl,-Map=$(TARGET).map,--cref<br />LDFLAGS += $(EXTMEMOPTS)<br />LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))<br />LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)<br />#LDFLAGS += -T linker_script.x<br /><br /><br /><br />#---------------- Programming Options (avrdude) ----------------<br /><br /># Programming hardware<br /># Type: avrdude -c ?<br /># to get a full listing.<br />#<br />AVRDUDE_PROGRAMMER = usbasp<br /><br /># com1 = serial port. Use lpt1 to connect to parallel port.<br />AVRDUDE_PORT = usb<br /><br />AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex<br />#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep<br /><br /><br /># Uncomment the following if you want avrdude's erase cycle counter.<br /># Note that this counter needs to be initialized first using -Yn,<br /># see avrdude manual.<br />#AVRDUDE_ERASE_COUNTER = -y<br /><br /># Uncomment the following if you do /not/ wish a verification to be<br /># performed after programming the device.<br />#AVRDUDE_NO_VERIFY = -V<br /><br /># Increase verbosity level.  Please use this when submitting bug<br /># reports about avrdude. See &lt;http://savannah.nongnu.org/projects/avrdude&gt; <br /># to submit bug reports.<br />#AVRDUDE_VERBOSE = -v -v<br /><br />AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)<br />AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)<br />AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)<br />AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)<br /><br /><br /><br />#---------------- Debugging Options ----------------<br /><br /># For simulavr only - target MCU frequency.<br />DEBUG_MFREQ = $(F_CPU)<br /><br /># Set the DEBUG_UI to either gdb or insight.<br /># DEBUG_UI = gdb<br />DEBUG_UI = insight<br /><br /># Set the debugging back-end to either avarice, simulavr.<br />DEBUG_BACKEND = avarice<br />#DEBUG_BACKEND = simulavr<br /><br /># GDB Init Filename.<br />GDBINIT_FILE = __avr_gdbinit<br /><br /># When using avarice settings for the JTAG<br />JTAG_DEV = /dev/com1<br /><br /># Debugging port used to communicate between GDB / avarice / simulavr.<br />DEBUG_PORT = 4242<br /><br /># Debugging host used to communicate between GDB / avarice / simulavr, normally<br />#     just set to localhost unless doing some sort of crazy debugging when <br />#     avarice is running on a different computer.<br />DEBUG_HOST = localhost<br /><br /><br /><br />#============================================================================<br /><br /><br /># Define programs and commands.<br />SHELL = sh<br />CC = avr-gcc<br />OBJCOPY = avr-objcopy<br />OBJDUMP = avr-objdump<br />SIZE = avr-size<br />AR = avr-ar rcs<br />NM = avr-nm<br />AVRDUDE = avrdude<br />REMOVE = rm -f<br />REMOVEDIR = rm -rf<br />COPY = cp<br />WINSHELL = cmd<br /><br /><br /># Define Messages<br /># English<br />MSG_ERRORS_NONE = Errors: none<br />MSG_BEGIN = -------- begin --------<br />MSG_END = --------  end  --------<br />MSG_SIZE_BEFORE = Size before: <br />MSG_SIZE_AFTER = Size after:<br />MSG_COFF = Converting to AVR COFF:<br />MSG_EXTENDED_COFF = Converting to AVR Extended COFF:<br />MSG_FLASH = Creating load file for Flash:<br />MSG_EEPROM = Creating load file for EEPROM:<br />MSG_EXTENDED_LISTING = Creating Extended Listing:<br />MSG_SYMBOL_TABLE = Creating Symbol Table:<br />MSG_LINKING = Linking:<br />MSG_COMPILING = Compiling C:<br />MSG_COMPILING_CPP = Compiling C++:<br />MSG_ASSEMBLING = Assembling:<br />MSG_CLEANING = Cleaning project:<br />MSG_CREATING_LIBRARY = Creating library:<br /><br /><br /><br /><br /># Define all object files.<br />OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) <br /><br /># Define all listing files.<br />LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) <br /><br /><br /># Compiler flags to generate dependency files.<br />GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d<br /><br /><br /># Combine all necessary flags and optional flags.<br /># Add target processor to flags.<br />ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)<br />ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)<br />ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)<br /><br /><br /><br /><br /><br /># Default target.<br />all: begin gccversion sizebefore build sizeafter end<br /><br /># Change the build target to build a HEX file or a library.<br />build: elf hex eep lss sym<br />#build: lib<br /><br /><br />elf: $(TARGET).elf<br />hex: $(TARGET).hex<br />eep: $(TARGET).eep<br />lss: $(TARGET).lss<br />sym: $(TARGET).sym<br />LIBNAME=lib$(TARGET).a<br />lib: $(LIBNAME)<br /><br /><br /><br /># Eye candy.<br /># AVR Studio 3.x does not check make's exit code but relies on<br /># the following magic strings to be generated by the compile job.<br />begin:<br />@echo<br />@echo $(MSG_BEGIN)<br /><br />end:<br />@echo $(MSG_END)<br />@echo<br /><br /><br /># Display size of file.<br />HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex<br />ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf<br /><br />sizebefore:<br />@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \<br />2&gt;/dev/null; echo; fi<br /><br />sizeafter:<br />@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \<br />2&gt;/dev/null; echo; fi<br /><br /><br /><br /># Display compiler version information.<br />gccversion : <br />@$(CC) --version<br /><br /><br /><br /># Program the device.  <br />program: $(TARGET).hex $(TARGET).eep<br />$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)<br /><br /><br /># Generate avr-gdb config/init file which does the following:<br />#     define the reset signal, load the target file, connect to target, and set <br />#     a breakpoint at main().<br />gdb-config: <br />@$(REMOVE) $(GDBINIT_FILE)<br />@echo define reset &gt;&gt; $(GDBINIT_FILE)<br />@echo SIGNAL SIGHUP &gt;&gt; $(GDBINIT_FILE)<br />@echo end &gt;&gt; $(GDBINIT_FILE)<br />@echo file $(TARGET).elf &gt;&gt; $(GDBINIT_FILE)<br />@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  &gt;&gt; $(GDBINIT_FILE)<br />ifeq ($(DEBUG_BACKEND),simulavr)<br />@echo load  &gt;&gt; $(GDBINIT_FILE)<br />endif<br />@echo break main &gt;&gt; $(GDBINIT_FILE)<br /><br />debug: gdb-config $(TARGET).elf<br />ifeq ($(DEBUG_BACKEND), avarice)<br />@echo Starting AVaRICE - Press enter when &quot;waiting to connect&quot; message displays.<br />@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \<br />$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)<br />@$(WINSHELL) /c pause<br /><br />else<br />@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \<br />$(DEBUG_MFREQ) --port $(DEBUG_PORT)<br />endif<br />@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)<br /><br /><br /><br /><br /># Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.<br />COFFCONVERT = $(OBJCOPY) --debugging<br />COFFCONVERT += --change-section-address .data-0x800000<br />COFFCONVERT += --change-section-address .bss-0x800000<br />COFFCONVERT += --change-section-address .noinit-0x800000<br />COFFCONVERT += --change-section-address .eeprom-0x810000<br /><br /><br /><br />coff: $(TARGET).elf<br />@echo<br />@echo $(MSG_COFF) $(TARGET).cof<br />$(COFFCONVERT) -O coff-avr $&lt; $(TARGET).cof<br /><br /><br />extcoff: $(TARGET).elf<br />@echo<br />@echo $(MSG_EXTENDED_COFF) $(TARGET).cof<br />$(COFFCONVERT) -O coff-ext-avr $&lt; $(TARGET).cof<br /><br /><br /><br /># Create final output files (.hex, .eep) from ELF output file.<br />%.hex: %.elf<br />@echo<br />@echo $(MSG_FLASH) $@<br />$(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $&lt; $@<br /><br />%.eep: %.elf<br />@echo<br />@echo $(MSG_EEPROM) $@<br />-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom=&quot;alloc,load&quot; \<br />--change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $&lt; $@ || exit 0<br /><br /># Create extended listing file from ELF output file.<br />%.lss: %.elf<br />@echo<br />@echo $(MSG_EXTENDED_LISTING) $@<br />$(OBJDUMP) -h -S -z $&lt; &gt; $@<br /><br /># Create a symbol table from ELF output file.<br />%.sym: %.elf<br />@echo<br />@echo $(MSG_SYMBOL_TABLE) $@<br />$(NM) -n $&lt; &gt; $@<br /><br /><br /><br /># Create library from object files.<br />.SECONDARY : $(TARGET).a<br />.PRECIOUS : $(OBJ)<br />%.a: $(OBJ)<br />@echo<br />@echo $(MSG_CREATING_LIBRARY) $@<br />$(AR) $@ $(OBJ)<br /><br /><br /># Link: create ELF output file from object files.<br />.SECONDARY : $(TARGET).elf<br />.PRECIOUS : $(OBJ)<br />%.elf: $(OBJ)<br />@echo<br />@echo $(MSG_LINKING) $@<br />$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)<br /><br /><br /># Compile: create object files from C source files.<br />$(OBJDIR)/%.o : %.c<br />@echo<br />@echo $(MSG_COMPILING) $&lt;<br />$(CC) -c $(ALL_CFLAGS) $&lt; -o $@ <br /><br /><br /># Compile: create object files from C++ source files.<br />$(OBJDIR)/%.o : %.cpp<br />@echo<br />@echo $(MSG_COMPILING_CPP) $&lt;<br />$(CC) -c $(ALL_CPPFLAGS) $&lt; -o $@ <br /><br /><br /># Compile: create assembler files from C source files.<br />%.s : %.c<br />$(CC) -S $(ALL_CFLAGS) $&lt; -o $@<br /><br /><br /># Compile: create assembler files from C++ source files.<br />%.s : %.cpp<br />$(CC) -S $(ALL_CPPFLAGS) $&lt; -o $@<br /><br /><br /># Assemble: create object files from assembler source files.<br />$(OBJDIR)/%.o : %.S<br />@echo<br />@echo $(MSG_ASSEMBLING) $&lt;<br />$(CC) -c $(ALL_ASFLAGS) $&lt; -o $@<br /><br /><br /># Create preprocessed source for use in sending a bug report.<br />%.i : %.c<br />$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $&lt; -o $@ <br /><br /><br /># Target: clean project.<br />clean: begin clean_list end<br /><br />clean_list :<br />@echo<br />@echo $(MSG_CLEANING)<br />$(REMOVE) $(TARGET).hex<br />$(REMOVE) $(TARGET).eep<br />$(REMOVE) $(TARGET).cof<br />$(REMOVE) $(TARGET).elf<br />$(REMOVE) $(TARGET).map<br />$(REMOVE) $(TARGET).sym<br />$(REMOVE) $(TARGET).lss<br />$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)<br />$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)<br />$(REMOVE) $(SRC:.c=.s)<br />$(REMOVE) $(SRC:.c=.d)<br />$(REMOVE) $(SRC:.c=.i)<br />$(REMOVEDIR) .dep<br /><br /><br /># Create object files directory<br />$(shell mkdir $(OBJDIR) 2&gt;/dev/null)<br /><br /><br /># Include the dependency files.<br />-include $(shell mkdir .dep 2&gt;/dev/null) $(wildcard .dep/*)<br /><br /><br /># Listing of phony targets.<br />.PHONY : all begin finish end sizebefore sizeafter gccversion \<br />build elf hex eep lss sym coff extcoff \<br />clean clean_list program debug gdb-config[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=9537">Raffaelloo</a> — 16 kwi 2015, o 14:07</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[PITERK]]></name></author>
<updated>2015-04-16T14:04:16+01:00</updated>
<published>2015-04-16T14:04:16+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126668#p126668</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126668#p126668"/>
<title type="html"><![CDATA[Re: WinAVR problem przy kompilacji]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126668#p126668"><![CDATA[
Witaj. <br />Podaj z jakiej strony pobrałeś program oraz wstaw kod który kompilujesz.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2913">PITERK</a> — 16 kwi 2015, o 14:04</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Raffaelloo]]></name></author>
<updated>2015-04-16T13:49:07+01:00</updated>
<published>2015-04-16T13:49:07+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126665#p126665</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126665#p126665"/>
<title type="html"><![CDATA[WinAVR problem przy kompilacji]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11393&amp;p=126665#p126665"><![CDATA[
Witam,<br />znalazłem w sieci gotowy program termometru. Chciałem go przetestować, ale ciągle pojawia Mi się problem przy kompilacji.<br />Pojawia się coś takiego:<br /><br />&gt; &quot;make.exe&quot; all<br /><br />-------- begin --------<br />avr-gcc (WinAVR 20100110) 4.3.3<br />Copyright (C) 2008 Free Software Foundation, Inc.<br />This is free software; see the source for copying conditions.  There is NO<br />warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br /><br />Compiling C: Atmega48PandMLX90614.c<br />avr-gcc -c -mmcu=atmega48p -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./Atmega48PandMLX90614.lst  -std=gnu99 -MMD -MP -MF .dep/Atmega48PandMLX90614.o.d Atmega48PandMLX90614.c -o Atmega48PandMLX90614.o <br />Atmega48PandMLX90614.c:73: warning: function declaration isn't a prototype<br />Atmega48PandMLX90614.c:82: warning: function declaration isn't a prototype<br />Atmega48PandMLX90614.c:88: warning: function declaration isn't a prototype<br />Atmega48PandMLX90614.c:94: warning: function declaration isn't a prototype<br />Atmega48PandMLX90614.c:100: warning: function declaration isn't a prototype<br />Atmega48PandMLX90614.c: In function 'i2c_refresh':<br />Atmega48PandMLX90614.c:117: warning: unused variable 'frac'<br /><br />Linking: Atmega48PandMLX90614.elf<br />avr-gcc -mmcu=atmega48p -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=Atmega48PandMLX90614.o  -std=gnu99 -MMD -MP -MF .dep/Atmega48PandMLX90614.elf.d Atmega48PandMLX90614.o --output Atmega48PandMLX90614.elf -Wl,-Map=Atmega48PandMLX90614.map,--cref     -lm<br />Atmega48PandMLX90614.o: In function `i2c_refresh':<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:104: undefined reference to `i2c_start'<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:105: undefined reference to `i2c_write'<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:107: undefined reference to `i2c_rep_start'<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:108: undefined reference to `i2c_readAck'<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:109: undefined reference to `i2c_readAck'<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:110: undefined reference to `i2c_readNak'<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:111: undefined reference to `i2c_stop'<br />Atmega48PandMLX90614.o: In function `main':<br />C:\Users\Rafael\Desktop\I2C/Atmega48PandMLX90614.c:133: undefined reference to `i2c_init'<br />make.exe: *** [Atmega48PandMLX90614.elf] Error 1<br /><br />&gt; Process Exit Code: 2<br />&gt; Time Taken: 00:01<br /><br />Projekt składa się z:<br />-Atmega48PandMLX90614.c<br />-I2CMaster.h<br />-I2Cmaster.s<br />-Makefile<br /><br />Próbowałem to skompilować w AVRStudio, ale pojawiają się te same błędy.<br />Jak rozwiązać ten problem?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=9537">Raffaelloo</a> — 16 kwi 2015, o 13:49</p><hr />
]]></content>
</entry>
</feed>