E ovako, ocu da napravim neku stvarcicu, iz novina ( info elektronika, u pitanju je Regulacija i evidencija sobne temperature) i sad u njima pise da se hex file nalazi na sajtu http://www.infoelektronika.net/articles.php?action=view ali kad odem tamo i otvorim link otvori mi se txt dokument u kojem ima :
"
/*
MikroKontroler: PIC16F877
Termosenzor : LM35DZ - analogni
RS232 komande:
void RS232_putst(register const char *str)
void RS232_putch(unsigned char c)
unsigned char RS232_getch() , 255 = nema podatka sa RS232
void DEBUG(register const char *debugtext)
*/
#include <pic.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "REST.h"
#include "delay.c"
#include "RS232.C"
__CONFIG(XT&WDTDIS&PWRTEN&BORDIS&LVPDIS&WRTDIS);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0,0,0,0,0,0,0,0);
__EEPROM_DATA(0x12,0x01,18,10,35,0,0,0);
//promenjive
unsigned char adrured,displej,serial;
bit timeout,cifra,rxin,manual;
unsigned int counter,offset,podeseno,maxtemp,mintemp;
unsigned long napon;
unsigned long ADC_VALUE;
unsigned char buffer[15];
int bytein=0,counter2;
//I-O portovi
static bit TasterGore @ PORTBIT(PORTD,1);
static bit TasterDole @ PORTBIT(PORTD,0);
static bit LedAdresa @ PORTBIT(PORTD,7);
static bit LedPodes @ PORTBIT(PORTD,6);
static bit Cifra0 @ PORTBIT(PORTE,0);
static bit Cifra1 @ PORTBIT(PORTE,1);
static bit RELE @ PORTBIT(PORTE,2);
static bit LED @ PORTBIT(PORTD,5);
unsigned char const DisplMask[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
#define DisplejPort PORTB
#define NAPONSKA_REFERENCA 500000 //podeseno 5V za ref. naponAD
void PodesavanjeTemperature(void)
{
LedPodes=1;
displej=podeseno; //na displ. se pokazuje podesena temp.
timeout=0;
TMR1ON=0;TMR1ON=1;
TMR1H=TMR1L=0;
while((!TasterGore || !TasterDole) && !timeout);
DelayMs(255);
while(!timeout && manual){
if(!TasterGore){ //taster GORE
TMR1ON=0;counter=SETTIME;
TMR1H=TMR1L=0;
podeseno=podeseno+1; //podeseno se povecacva
if(podeseno>maxtemp) podeseno=maxtemp; //nemoze ispod MIN vrednosti
displej=podeseno; //na displ. se prikazuje vrednost
eeprom_write(EE_PODESENO,podeseno);
DelayMs(255);
TMR1ON=1;
}
if(!TasterDole){
TMR1ON=0;counter=SETTIME;
TMR1H=TMR1L=0;
podeseno=podeseno-1;
if(podeseno<mintemp) podeseno=mintemp;
displej=podeseno;
eeprom_write(EE_PODESENO,podeseno);
DelayMs(255);
TMR1ON=1;
}
}
timeout=1;LedPodes=0;
}
void interrupt isr(void)
{
int dspm;
GIE=0;
if(T0IF){
if(!cifra){ //1.displej
Cifra1=0;
dspm=displej%10;
DisplejPort=DisplMask[dspm];
Cifra0=1;
}
if(cifra) { //2.displej
Cifra0=0;
dspm=displej/10;
DisplejPort=DisplMask[dspm];
Cifra1=1;
}
cifra=!cifra;
T0IF=0;
}
if(TMR1IF){
if(counter==0){
timeout=1;
TMR1ON=0;
counter=SETTIME;
TMR1IF=0;
}
else counter--;
}
if(RCIF){
buffer[bytein]=RCREG;
if(buffer[bytein]=='*') rxin=1;
bytein++;
if(bytein>15) bytein=15;
RCIF=0;
}
GIE=1;
}
void RXin()
{
unsigned char *puff;
int adresa;
LedAdresa=1;
TMR1ON=0;
puff=strtok(buffer,"-=*");
adresa=atoi(puff);
if(adresa==adrured){
puff=strtok(NULL,"-=*");
if(strcmp(puff,"GET")==0){
RS232_putst("TEMP=");
RS232_dec2str2(napon);
RS232_putst(";");
} else if(strcmp(puff,"SET")==0){
puff=strtok(NULL,"-=*");
podeseno=atoi(puff);
RS232_putst("SET=");
RS232_dec2str2(podeseno);
RS232_putst(";");
eeprom_write(EE_PODESENO,podeseno);
DelayMs(10);
} else if(strcmp(puff,"GSET")==0){
RS232_putst("SET=");
RS232_dec2str2(podeseno);
RS232_putst(";");
} else if(strcmp(puff,"GMIN")==0){
RS232_putst("MIN=");
RS232_dec2str2(mintemp);
RS232_putst(";");
} else if(strcmp(puff,"GMAX")==0){
RS232_putst("MAX=");
RS232_dec2str2(maxtemp);
RS232_putst(";");
} else if(strcmp(puff,"GMANUAL")==0){
RS232_putst("MANUAL=");
RS232_dec2str2(offset);
RS232_putst(";");
}else if(strcmp(puff,"MIN")==0){
puff=strtok(NULL,"-=*");
mintemp=atoi(puff);
RS232_putst("MIN=");
RS232_dec2str2(mintemp);
RS232_putst(";");
eeprom_write(EE_MIN,mintemp);
DelayMs(10);
}else if(strcmp(puff,"MAX")==0){
puff=strtok(NULL,"-=*");
maxtemp=atoi(puff);
RS232_putst("MAX=");
RS232_dec2str2(maxtemp);
RS232_putst(";");
eeprom_write(EE_MAX,maxtemp);
DelayMs(10);
}else if(strcmp(puff,"MANUAL")==0){
puff=strtok(NULL,"-=*");
offset=atoi(puff);
if(offset==1) manual=1;
else manual=0;
RS232_putst("MANUAL=");
RS232_dec2str2(offset);
RS232_putst(";");
eeprom_write(EE_OFFSET,offset);
DelayMs(10);
}else RS232_putst("<NotDef>;"); //Nedefinisana poruka
}
bytein=0;rxin=0;timeout=0;
counter=SETTIME;TMR1ON=1;
LedAdresa=0;
}
void main(void)
{
TRISA=0xFF;
TRISE=0x00; //display
TRISB=0x00; //portb je izlazni
TRISD=0b0001111; //od RD5 do RD7 izalazni, ostalo ulazni
TRISC=0xFF;
GIE=1;
ADCON1=0x8E; //RA0 analogni input, ostali digitalni
cifra=0;
PORTE=0;
Cifra0=0;Cifra1=0;
OPTION=0b10000000; // Ukljucuje prekidnu rutinu za displej
T0IE=1;
T1CON=0b1111001;
//RS485 komunikacija
rxin=0;
BRGH=1;
SPBRG=12; //19200 bautrate
TX9=0;RX9=0;
SYNC=0;SPEN=1;TXEN=1;
CREN=1;RCIE=1;
DEBUG(" REST is ON ");
LedAdresa=0; //iskljuci LED
LedPodes=0;
adrured=eeprom_read(EE_ADRESA);
podeseno=eeprom_read(EE_PODESENO);
offset=eeprom_read(EE_OFFSET);
mintemp=eeprom_read(EE_MIN);
maxtemp=eeprom_read(EE_MAX);
if(offset==1) manual=1;
else manual=0;
// **** GLAVNI PROGRAM ****
//TEST SVIH LED-a i RELE-a
RELE=1;LED=1;
displej=88;
LedAdresa=1; LedPodes=1;
DelayMs(255);DelayMs(255);
DelayMs(255);DelayMs(255);
RELE=0;LED=0;LedAdresa=0;LedPodes=0;
//..kraj TEST-a
TMR1ON=1;counter=SETTIME;timeout=1;
//bezkrajni ciklus
DEBUG(" while ciklus ");
while(1){
if(rxin) RXin();
if(!TasterGore || !TasterDole) {
counter=SETTIME;
PodesavanjeTemperature();
DelayMs(255);
}
if(timeout){
napon=(NAPONSKA_REFERENCA/1024); //10bit-1024; 8bit-256
ADCON0=64+(0x00)+1; //Fosc/8; channel 0; AD uklj.
DelayUs(2);
ADRESL=0;ADRESH=0;
ADGO=1;
while(ADGO); //cekamo kraj konverzije
ADC_VALUE=ADRESH;
ADC_VALUE=ADC_VALUE<<8;
ADC_VALUE+=ADRESL;
//ADC_VALUE=ADRESL; //Csak 8 bittes pontossag
napon*=ADC_VALUE;
napon/=11; //OP pojacava 11 puta
napon/=1000;napon-=offset;
displej=napon;
if(napon<(podeseno-HISTEREZA)) { RELE=1; LED=1; }
if(napon>=podeseno) { RELE=0; LED=0; }
timeout=0;TMR1ON=1;counter=SETTIME;
}
}
}
"
E sad sta sa ovim raditi, u cemu ja to da uradim, da bi napravio hex file sto mi treba za taj pic kontroler ?
Trazim malo obasnjenje u vezi HEX-a
Moderators: pedja089, stojke369, [eDo], trax, LAF
- MladaNada
- Stariji član
- Posts: 2529
- Joined: 20-05-2006, 14:57
- Location: Banja Luka RS , Novi Sad RS , Herceg Novi CG
Mislim da je to pisano u C-u! Probaj kompajlirati u .exe u nekom c kompajleru , pa pretvoriti u .asm dissasemblerom ( http://www.safesite.com/category.php%5B ... %5Ddigibuy ) , pa onda u .hex . Vjerovatno postoji jednostavniji nacin!