Obtener el Hex de un programa en C

hola a todos my username es coconut y me gusta cacharrear con micros y encontre un programa para un termistor pero se encuentra en C y me he vuelto un ocho tratando de compilarlo para obtener el Hex de este si alguien me puede colaborar se lo agradeceria y el programa es

Código:
/**********************************************************************/
/*                                                                    */
/* Termometro.c */
/* Termómetro degital usando termistor */
/* para el PIC16F873 */
/* */
/* */
/* Autor: Carlos Narvaez 15/06/2004 */
/* Rutina LCD Original: J. Winpenny */
/* */
/*--------------------------------------------------------------------*/
/* LCD : OPTREX Corporation DMC16249UB */
/* LCD tipo: HD44780 */
/* Compilador: CSC PCM C compiler */
/* termistor: 10K @ 25°C */
/* */
/* Interfaces: */
/* */
/* Termistor = Port A bit 0 */
/* Data_5 = Port B bit 0 */
/* Data_6 = Port B bit 1 */
/* Data_7 = Port B bit 2 */
/* Data_6 = Port B bit 3 */
/* RS = Port B bit 4 */
/* W/R = Port B bit 5 */
/* Enable = Port B bit 6 */
/* Esta version es para el modo de operación 4 bit */
/* */
/* */
/**********************************************************************/
#include <16f873.h>
#device ADC=10
#include <math.h>
#fuses XT,NOWDT,PUT, NOPROTECT, NOBROWNOUT,NOLVP,WRT,NOCPD
#use delay (clock=4000000)
/**********************************************************************/
/* Prototipos */
/**********************************************************************/
void LCD_Setup(void);
void LCD_FunctionMode(void);
void LCD_DataMode(void);
void LCD_Write_8_Bit(char);
void LCD_Write_4_Bit(char);
void LCD_Delay(void);
void delay_s(int);
void calcule_temp(long int);
void write_temp(void);
//void WriteLCDString( const char *lcdptr );
/**********************************************************************/
/* Definiciones Generales */
/**********************************************************************/
#byte OPTION_REG = 0x81
long int adc_var;
float r_term, T_C, LnRes, LnRes3;

/**********************************************************************/
/* Definiciones para la interfaz PIC-LCD */
/**********************************************************************/
#define TER_IN PIN_A0 /* Interfaz Termistor-PIC */
#define LCD_DATA_4 PIN_B0 /* LCD BIT 4 */
#define LCD_DATA_5 PIN_B1 /* LCD BIT 5 */
#define LCD_DATA_6 PIN_B2 /* LCD BIT 6 */
#define LCD_DATA_7 PIN_B3 /* LCD BIT 7 */
#define LCD_RS PIN_B4 /* Register Select */
#define LCD_WR PIN_B5 /* Escribir/Leer */
#define LCD_SEL PIN_B6 /* Habilita LCD */
/* */
/* */
/**********************************************************************/
/* Comandos del LCD ( Segun LCD Data Sheet ) */
/**********************************************************************/
/* */
#define clear_lcd 0x01 /* Clear Display */
#define return_home 0x02 /* Cursor to Home position */
#define entry_mode 0x06 /* Normal entry mode */
#define entry_mode_shift 0x07 /* - with shift */
#define system_set_8_bit 0x38 /* 8 bit data mode 2 line ( 5x7 font ) */
#define system_set_4_bit 0x28 /* 4 bit data mode 2 line ( 5x7 font ) */
#define display_on 0x0c /* Switch ON Display */
#define display_off 0x08 /* Cursor plus blink */
#define set_dd_line1 0x80 /* Line 1 position 1 */
#define set_dd_line2 0xC0 /* Line 2 position 1 */
#define set_dd_ram 0x80 /* Line 1 position 1 */
#define write_data 0x00 /* With RS = 1 */
#define cursor_on 0x0E /* Switch Cursor ON */
#define cursor_off 0x0C /* Switch Cursor OFF */
/* */
/**********************************************************************/
/* Variables configuracion del PIC */
/**********************************************************************/
#define TxMode 0x40 /* Set option reg TMR0 interrupt */
/* source from counter. */
/* Max speed prescaler ( 1:2 ) */
/* ( Not needed for LCD ) */
#define PortAConfig 0x01 /* Configure port A ( 1 = input ) */
/* RA4/RTCC = Input / RA2 = Input */
#define PortBConfig 0x00 /* Configure port B */
/**********************************************************************/
/* Programa Principal */
/**********************************************************************/
void main(void)
{
/* Configuración puertos PIC e Interrucciones */
OPTION_REG = TxMode; /* Set Option register.*/
set_tris_a( PortAConfig); /* Setup ports */
set_tris_b( PortBConfig );
output_low(LCD_SEL);
disable_interrupts(GLOBAL);
setup_adc_ports(RA0_ANALOG);
setup_adc(ADC_CLOCK_DIV_32);
SET_ADC_CHANNEL(0);
/* End of Setup */

LCD_Setup(); /* Setup the LCD device */
LCD_Write_4_Bit('T'); /* Display a test message */
LCD_Write_4_Bit('E');
LCD_Write_4_Bit('R');
LCD_Write_4_Bit('M');
LCD_Write_4_Bit('O');
LCD_Write_4_Bit('M');
LCD_Write_4_Bit('E');
LCD_Write_4_Bit('T');
LCD_Write_4_Bit('R');
LCD_Write_4_Bit('O');
delay_s(5);
LCD_FunctionMode();
LCD_Write_4_Bit(set_dd_line2); /* Goto line 2 */
LCD_DataMode();
while( 1 )
{
adc_var = READ_ADC();
delay_us(10);
calcule_temp(adc_var);
write_temp();
LCD_FunctionMode();
LCD_Write_4_Bit(set_dd_line2); /* Goto line 2 */
LCD_DataMode();
delay_s(5);
}
}
/* END OF MAIN */
/***********************************/
/* Setup the lcd device */
/***********************************/
void LCD_Setup(void)
{
/* Reset the LCD */
delay_ms(30); /* Power up delay */
LCD_FunctionMode();
LCD_Write_8_Bit( system_set_4_bit ); /* This sequence resets the LCD */
delay_ms(5);
LCD_Write_8_Bit( system_set_4_bit );
delay_ms(5);
LCD_Write_8_Bit( system_set_4_bit );
delay_ms(5);
LCD_Write_4_Bit( system_set_4_bit );
delay_ms(2);
LCD_Write_4_Bit( display_off );
delay_ms(2);
LCD_Write_4_Bit( entry_mode );
delay_ms(2);
LCD_Write_4_Bit( display_on );
delay_ms(2);
LCD_Write_4_Bit( set_dd_ram );
delay_ms(2);
LCD_DataMode();
}
/***********************************/
/* LCD modo comandos */
/***********************************/
void LCD_FunctionMode(void)
{
output_low(LCD_RS);
LCD_Delay();
}
/***********************************/
/* LCD modo Data */
/***********************************/
void LCD_DataMode(void)
{
output_high(LCD_RS);
LCD_Delay();
}
/***********************************/
/* Escribe un byte en el LCD */
/* Modo 8 Bit */
/***********************************/
void LCD_Write_8_Bit(char d )
{
output_low(LCD_WR); /* modo Write */
LCD_Delay();
/* Setup data */
if ( d & 0x80 )
output_high(LCD_DATA_7);
else output_low(LCD_DATA_7);
if ( d & 0x40 )
output_high(LCD_DATA_6);
else output_low(LCD_DATA_6);
if ( d & 0x20 )
output_high(LCD_DATA_5);
else output_low(LCD_DATA_5);
if ( d & 0x10 )
output_high(LCD_DATA_4);
else output_low(LCD_DATA_4);
LCD_Delay();
output_high(LCD_SEL); /* Select LCD */
LCD_Delay();
output_low(LCD_SEL); /* De-select LCD */
/***********************************/
/* Escribe un byte en el LCD */
/* Modo 4 Bit */
/***********************************/
void LCD_Write_4_Bit(char d )
{
output_low(LCD_WR); /* Write Mode */
LCD_Delay();
/* Output Higher 4 bits */
if ( d & 0x80 )
output_high(LCD_DATA_7);
else output_low(LCD_DATA_7);
if ( d & 0x40 )
output_high(LCD_DATA_6);
else output_low(LCD_DATA_6);
if ( d & 0x20 )
output_high(LCD_DATA_5);
else output_low(LCD_DATA_5);
if ( d & 0x10 )
output_high(LCD_DATA_4);
else output_low(LCD_DATA_4);
LCD_Delay();
output_high(LCD_SEL);
LCD_Delay();
output_low(LCD_SEL); /* Clock in the data */
LCD_Delay();
d <<= 4; /* Output Lower 4 bits */
if ( d & 0x80 )
output_high(LCD_DATA_7);
else output_low(LCD_DATA_7);
if ( d & 0x40 )
output_high(LCD_DATA_6);
else output_low(LCD_DATA_6);
if ( d & 0x20 )
output_high(LCD_DATA_5);
else output_low(LCD_DATA_5);
if ( d & 0x10 )
output_high(LCD_DATA_4);
else output_low(LCD_DATA_4);
LCD_Delay();
output_high(LCD_SEL);
LCD_Delay();
output_low(LCD_SEL); /* Clock in the data */
}
/***********************************/
/* Retardo temporal para LCD */
/* Adjuste segun el LCD que use */
/***********************************/
void LCD_Delay(void)
{
delay_ms(1);
}
/***********************************/
/* Retardo segundos */
/***********************************/
void delay_s(int n)
{
for (;n!=0; n--)
delay_ms(1000);
}
/***********************************/
/* Calculo de Temperatura */
/***********************************/
void calcule_temp(long int adc_var)
{
r_term = ((10.0*adc_var)/(1024-adc_var));
LnRes = log(r_term);
LnRes3 = LnRes*LnRes*LnRes;
T_C = (1/(0.00269794+0.00028033*LnRes+0.00000086*LnRes3))-273.15;
}
/***********************************/
/* Escribe Tempertura en LCD */
/***********************************/
void write_temp(void)
{
printf(LCD_Write_4_Bit, "%5.2f", T_C);
}
 

Adjuntos

  • prog1_326.txt
    8.3 KB · Visitas: 11
/* Compilador: CSC PCM C compiler */
/* termistor: 10K @ 25°C */
----------------
en esta linea viene el programa que te hace el HEX.
si quieres trastear con micros es fundamental que lo tengas.
de todas formas, si quieres el hex...
te lo pongo ahora.
 
Hola, le cuento que tambien estoy realizando el mismo trabajo, pude compilarlo con el csc pic compiler, con el compilador que el publicador sugiere. me gustaria saber cómo le ha ido con el trabajo. pq la verdad yo ya hice todo lo que en el informe dice con los respectivos materiales. Pero a mi, cuando los datos se muestran en el Lcd me salen temperauras inesperadas. he estado en constante contacto con quien lo publico y el me ha dado unas pautas, pero la vdd me interesaria saber como le ha ido a ud.

Suerte!
 
Atrás
Arriba