Juz byl taki temat ale został zamknięty. Moj problem polega na tym ze nie moge ruszyc ds1820 w C z wykorzystaniem bliotek rklib do obslugi ds.
pliki make oraz config
make:
config
podlaczony jest do PORTU D.0 wogole nic nie reaguje na lcd tylko 0.0. standardowe podlaczenie jak w nocie. Dodam ze napisalem program w Bascomie i wszystko dobrze smiga. Oscylator wewnetrzny ustawiony na 8MHz. Prosze o pomoc bo nie wiem co źle robie
plik do obslugi ds
#include <avr/io.h>
#include<avr/interrupt.h>
#include<avr/eeprom.h>
#include<string.h>
#include "lcd.h"
#include "ds18x20.h"
#include "delay.h"
uint8_t gSensorIDs[OW_ROMCODE_SIZE];
int main(void)
{
uint16_t decicelsius;
uint8_t diff, i, subzero, cel, cel_frac_bits;
LCD_init();
#ifndef OW_PORT
OW_set_bus(&PORTD,0);
#endif
while(1)
{
DS18X20_start_meas( DS18X20_POWER_PARASITE, NULL);
delayms( DS18B20_TCONV_12BIT );
DS18X20_read_meas_single(0x28, &subzero, &cel, &cel_frac_bits );
decicelsius = DS18X20_temp_to_decicel(subzero, cel, cel_frac_bits );
LCD_xy(0,0);
LCD_putstr_P(PSTR("Temp: "));
LCD_putchar( (subzero)?'-':'+' );
LCD_putint( ((decicelsius/10)),10) ;
LCD_putchar(',');
LCD_putchar( (decicelsius%10) + '0');
}
}
pliki make oraz config
make:
# Nazwa pliku z funkcją main() - BEZ ROZSZERZENIA!
TARGET = bibl
CONFIG=config.h
# typ mikrokontrolera
#MCU = at90s2313
#MCU = at90s8515
#MCU = atmega163
MCU = atmega8
#MCU = atmega128
# Katalog z bibliotekami użytkownika
USRLIB = ../../lib
# Lista plików źródłowych bibliotek w języku C
SRCLIB =
#include $(USRLIB)/adc_pwm/sources
#include $(USRLIB)/conv/sources
include $(USRLIB)/lcd/sources
#include $(USRLIB)/i2c/sources
#include $(USRLIB)/led7seg/sources
#include $(USRLIB)/kbd/sources
include $(USRLIB)/delay/sources
#include $(USRLIB)/pcf8583/sources
#include $(USRLIB)/uart/sources
include $(USRLIB)/onewire/sources
include $(USRLIB)/ds18x20/sources
# Lista plików źródłowych w języku C
SRC = $(TARGET).c
# Lista plików źródłowych w asemblerze (rozszerzenie S - DUŻE S !)
ASRC =
# Format pliku wyjściowego (srec, ihex)
FORMAT = ihex
# Poziom optymalizacji (0, 1, 2, 3, s)
# (Uwaga: 3 nie zawsze jest najlepszym wyborem)
OPT = s
# Dodatkowe biblioteki
#
# Minimalna wersja printf
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
#
# Zmiennoprzecinkowa wersja printf (wymaga biblioteki matematycznej)
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
#
# Biblioteka matematyczna
#LDFLAGS += -lm
include $(USRLIB)/avr_makeconfig
#define F_CPU 8000000 //częstotliwość zegara w Hz
#define OW_PORT PORTD
#define OW_BIT 0
//----------------------
// LCD
//----------------------
#define LCD_PORT PORTC //port wyświetlacza
#define LCD_RS 5 //bit linii RS
#define LCD_EN 4 //bit linii EN
#define LCD_X 16 //liczba znaków w linii wyświetlacza
#define LCD_Y 2 //liczba wierszy wyświetlacza
//#define LCD_BIT_SWAP //zamiana bitów danych LCD D3<>D0, D2<>D1
#define LCD_WRAP //zawijanie tekstu
#define LCD_WIN1250 //polskie znaki wg WIN1250
podlaczony jest do PORTU D.0 wogole nic nie reaguje na lcd tylko 0.0. standardowe podlaczenie jak w nocie. Dodam ze napisalem program w Bascomie i wszystko dobrze smiga. Oscylator wewnetrzny ustawiony na 8MHz. Prosze o pomoc bo nie wiem co źle robie
plik do obslugi ds
#ifndef DS18X20_H_
#define DS18X20_H_
/*! \file ds18x20.h \brief Obsługa termometru 1-wire DS18x20 */
/*
Copyright (c) 2005 Robert Krysztof
robert.krysztof@wp.pl
http://www.avr-gcc.prv.pl
*/
/** \defgroup ds18x20 Termometr 1-wire DS18x20
Obsługa termometru 1-wire DS18x20.
\code
#include "ds18x20.h "
\endcode
\ref config:
W pliku \c "config.h" znajdującym się w katalogu projektu należy umieścić następującą zawartość:
\code
#define OW_PORT PORTD
#define OW_BIT 2
\endcode
\note Wartości z \c #define można zmieniać w celu dostosowania
biblioteki do tworzonego urządzenia i oprogramowania.
*/
#include <stdlib.h>
#include <inttypes.h>
#include "onewire.h"
/* return values */
#define DS18X20_OK 0x00
#define DS18X20_ERROR 0x01
#define DS18X20_START_FAIL 0x02
#define DS18X20_ERROR_CRC 0x03
#define DS18X20_POWER_PARASITE 0x00
#define DS18X20_POWER_EXTERN 0x01
/* DS18X20 specific values (see datasheet) */
#define DS18S20_ID 0x10
#define DS18B20_ID 0x28
#define DS18X20_CONVERT_T 0x44
#define DS18X20_READ 0xBE
#define DS18X20_WRITE 0x4E
#define DS18X20_EE_WRITE 0x48
#define DS18X20_EE_RECALL 0xB8
#define DS18X20_READ_POWER_SUPPLY 0xB4
#define DS18B20_CONF_REG 4
#define DS18B20_9_BIT 0
#define DS18B20_10_BIT (1<<5)
#define DS18B20_11_BIT (1<<6)
#define DS18B20_12_BIT ((1<<6)|(1<<5))
// indefined bits in LSB if 18B20 != 12bit
#define DS18B20_9_BIT_UNDF ((1<<0)|(1<<1)|(1<<2))
#define DS18B20_10_BIT_UNDF ((1<<0)|(1<<1))
#define DS18B20_11_BIT_UNDF ((1<<0))
#define DS18B20_12_BIT_UNDF 0
// conversion times in ms
#define DS18B20_TCONV_12BIT 750
#define DS18B20_TCONV_11BIT DS18B20_TCONV_12_BIT/2
#define DS18B20_TCONV_10BIT DS18B20_TCONV_12_BIT/4
#define DS18B20_TCONV_9BIT DS18B20_TCONV_12_BIT/8
#define DS18S20_TCONV DS18B20_TCONV_12_BIT
// constant to convert the fraction bits to cel*(10^-4)
#define DS18X20_FRACCONV 625
#define DS18X20_SP_SIZE 9
// DS18X20 EEPROM-Support
#define DS18X20_WRITE_SCRATCHPAD 0x4E
#define DS18X20_COPY_SCRATCHPAD 0x48
#define DS18X20_RECALL_E2 0xB8
#define DS18X20_COPYSP_DELAY 10 /* ms */
#define DS18X20_TH_REG 2
#define DS18X20_TL_REG 3
/* for description of functions see ds18x20.c */
extern void DS18X20_find_sensor(uint8_t *diff,
uint8_t id[]);
extern uint8_t DS18X20_get_power_status(uint8_t id[]);
extern uint8_t DS18X20_start_meas( uint8_t with_external,
uint8_t id[]);
extern uint8_t DS18X20_read_meas(uint8_t id[],
uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits);
extern uint8_t DS18X20_read_meas_single(uint8_t familycode,
uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits);
extern uint8_t DS18X20_meas_to_cel( uint8_t fc, uint8_t *sp,
uint8_t* subzero, uint8_t* cel, uint8_t* cel_frac_bits);
extern uint16_t DS18X20_temp_to_decicel(uint8_t subzero, uint8_t cel,
uint8_t cel_frac_bits);
extern int8_t DS18X20_temp_cmp(uint8_t subzero1, uint16_t cel1,
uint8_t subzero2, uint16_t cel2);
// write th, tl and config-register to scratchpad (config ignored on S20)
uint8_t DS18X20_write_scratchpad( uint8_t id[],
uint8_t th, uint8_t tl, uint8_t conf);
// read scratchpad into array SP
uint8_t DS18X20_read_scratchpad( uint8_t id[], uint8_t sp[]);
// copy values th,tl (config) from scratchpad to DS18x20 eeprom
uint8_t DS18X20_copy_scratchpad( uint8_t with_power_extern,
uint8_t id[] );
// copy values from DS18x20 eeprom to scratchpad
uint8_t DS18X20_recall_E2( uint8_t id[] );
#endif
