Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help! what source code is it? for mplab, c+ or ccs...

Status
Not open for further replies.

Cleong

Member level 2
Joined
Feb 17, 2006
Messages
53
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,789
button_pressed, beispiel c,code

#include <18f452.h> // device selection
#device adc=10 *=16
#include <STDLIB.H> // needed for division routine

#fuses XT,NOWDT,NOPROTECT,NOLVP,PUT,NOBROWNOUT,NOOSCSEN,CCP2C1,NOSTVREN,NODEBUG

#use delay(clock=4000000) // 4 MhZ ! ADC is not optimal at 20 MhZ + power consumption doubles

#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
#use i2c(master, sda=PIN_C4, scl=PIN_C3, slow)

#zero_ram

// #PRIORITY

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#use fast_io(E)

#define NOP #asm nop #endasm

#byte pa =0xF80 //port a // analog
#byte pb =0xF81 //b // spi & sensor controls
#byte pc =0xF82 //c // i淆 & timing
#byte pd =0xF83 //d // LCD
#byte pe =0xF84 //port e // keys

// *********************************
// PORT A
// analog inputs

// A1= barometer input from mpx4115a
// A2= -Vref 2.400 V
// A3= +Vref 4.700 V


// *********************************
// PORT B: sensor controls + menu key

// emulated SPI bits
#bit TC77_CS =pb.7 // RB7 pin40, TC77 !CS
#bit TC77_SIO =pb.6 // RB6 pin39, TC77 S I/O
#bit TC77_SCK =pb.5 // RB5 pin38, TC77 SCK

#bit key_enter =pb.0 // RB0, pin33
#bit key_plus =pb.1 // RB1, pin34
#bit key_min =pb.2 // RB2, pin35

#bit MPX4115A_POWER =pb.3 // RB3 pin36, "1" = MPX4115A OFF (switches the module completely on or off)
#bit RH_POWER =pb.4 // RB4 pin37

// *********************************
// PORT C
// i淆 & timer inputs


// T1 external input (hardware) // RC0 pin15
// this is 1 Hz input from RTC DS1307 (for wake-up from sleep) AND input RH (H1 sensor)
#bit CP1 =pc.2 // RC2 pin17 **** RX RADIO


// RC3 pin18 = SCL i淆 // already defined (hardware)
// RC4 pin23 = SDA i淆

// RC6 pin25 = RS232 TX // already defined (hardware)
// RC7 pin26 = RS232 RX

// *********************************
// PORT D
// LCD bits + lobat detect

#bit lobat =pd.1 // RD1

#bit nok_sclk =pd.5 // RD5
#bit nok_sda =pd.4 // RD4
#bit nok_dc =pc.5 // RC5
#bit nok_cs =pd.3 // RD3
#bit nok_res =pd.2 // RD2

// *********************************
// PORT E
// 1 sensor control

#bit RX433_POWER =pe.2 // RE2 pin10

// *********************************

//
#SEPARATE void key_sel(void); // for key inputs
char k_min,k_plus,k_enter;
//

//
void sleep_routine(void); // for sleep mode
static short sleep_mode;
static char tosleep_counter;

#define sleeping_period 45 // approx. time of sleep in seconds (normally around 45) *************************************
//

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#INT_EXT // waking up from BO / INT0
void ext_isr(void)
{
static short button_pressed=FALSE;

if(button_pressed){sleep_mode=FALSE;tosleep_counter=0;k_enter=1;}
else{sleep_mode=TRUE;}


if(input(PIN_B0)){button_pressed=TRUE;}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#INT_EXT1 // waking up from B1 / INT1
void ext1_isr(void)
{
static short button_pressed=FALSE;

if(button_pressed){sleep_mode=FALSE;tosleep_counter=0;k_plus=1;}
else{sleep_mode=TRUE;}

if(input(PIN_B1)){button_pressed=TRUE;}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#INT_EXT2 // waking up from B2 / INT2
void ext2_isr(void)
{
static short button_pressed=FALSE;

if(button_pressed){sleep_mode=FALSE;tosleep_counter=0;k_min=1;}
else{sleep_mode=TRUE;}

if(input(PIN_B2)){button_pressed=TRUE;}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#INT_TIMER1 // waking up from T1 overflow
void timer1_isr(void)
{

if(tosleep_counter==0){sleep_mode=FALSE;}
else {sleep_mode=TRUE;}


}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void update_interval(void);
//
int16 h;
char hist_sel;
int16 hist_index,curr_index; // for graphical stuff
signed int16 diff_hi_lo,tt_in_hi,tt_in_lo,t_value,tt_value;
void show_histories(void);


//
char char_row,charsel,charpos,chardata; // for nokia_3310 lcd
int16 ddram;
char plot_value;
int32 plot_value32;
int32 plot_umsb,plot_lmsb,plot_ulsb,plot_llsb;
#include <lph7779_v3.c>

//
void tc77_read(void); // fot SPI temperature sensor TC77
signed int16 t_in,t_unused;
float tc_in_float;
float tf_in_float;
char tc77_ready;
void tc77_write(short bitfortc77);

float t_in_hi,t_in_lo,t_in_temp;
void store_t_in(void);
void show_t_in_graph(void);
//

//
void mpx4115a_read(); // for pressure sensor MPX4115A
int16 p_an;
int16 adc_sample;
float p_hPa_float;
float p_inHg_float;
char p_corr;
float press_hi,press_lo,press_temp;
void store_press(void);
void show_press_graph(void);
//

//
void rhum_read(void); // for relative humidity (RH)
void rhum_convert(void);
int16 rh_count,rh_count2;
char rh_corr;
char rh_procent;
char rh_hi,rh_lo,rh_temp;
void store_rh(void);
void show_rh_graph(void);
//

// // for ds1307
byte rtc_data;
char rtensec,rsec,rtenmin,rmin,rtenhour,rhour,rday,rtendate,rdate,rmonth,rtenyear,ryear;
#include <ds1307_mb_v1.c>
//

//
#include <24256_mb.c> // for ext eeprom
EEPROM_ADDRESS address;
//

//
signed char displ_mod; // for user menu
signed char temp_outp;
signed char press_outp;
#include <menu_012.c>
//

//
char rx_status; // for RX Radio routines
int16 rx_valid_in_loop;
char bitcount;
short bit_RC5,bit_prev;
char sample_RC5;
int32 rx_temp_int32;
int16 rise,fall;
short rxnewsequence;
float tc_ex_float;
float tf_ex_float;
short rx_lobat;
short rx_minus;
char tc_ex_0,tc_ex_1,tc_ex_2;
#include <rx_radio_012.c>
float t_ex_hi,t_ex_lo,t_ex_temp;
void store_t_ex(void);
void show_t_ex_graph(void);

//


WRITE_FLOAT_EXT_EEPROM(long int n, float data)
{
int i;

for (i = 0; i < 4; i++)
write_ext_eeprom(i + n, *(&data + i) ) ;
}


float READ_FLOAT_EXT_EEPROM(long int n)
{
int i;
float data;

for (i = 0; i < 4; i++)
*(&data + i) = read_ext_eeprom(i + n);

return(data);
}

void main(){


SET_TRIS_A(0x0f); // oooo iiii
SET_TRIS_B(0x47); // oioo oiii
SET_TRIS_C(0x9f); // iooi iiii
SET_TRIS_D(0x02); // oooo ooio
SET_TRIS_E(0x00); // oooo oooo

sleep_mode=FALSE; // init sleep flag
tosleep_counter=0;

printf("Weather Station\n\r"); // RS232 test

ds1307_write(7,0x80); // disable SQWE out on DS1307
TC77_CS=1; // deselect the TC77 (RB7)

MPX4115A_POWER=1; // power-off for the mpx4115a (RB4)
RH_POWER=1; // power-off for the H1-circuit (RA4)
RX433_POWER=1; // power-off for the RX433 (RA5)

nokia_init(); // lph7779 init


rtc_data=ds1307_read(2); // init RTC -- ds1307_write(byte rtcreg, byte rtc_data)
ds1307_write(2,(rtc_data&0x3f)); // set 24h mode -- reg 2, bit 6= 0

rtc_data=ds1307_read(0); // init RTC -- ds1307_write(byte rtcreg, byte rtc_data)
if ((rtc_data&0x80)==0x80){ds1307_write(0,(rtc_data&0x7f));} // enable DS1307 oscillator -- reg 0, bit 7= 0 -- CH= 0

temp_outp=read_ext_eeprom(0x0003); // load user presets
press_outp=read_ext_eeprom(0x0004);
p_corr=read_ext_eeprom(0x0005);
rh_corr=read_ext_eeprom(0x0006);

rx_valid_in_loop=250;


t_ex_hi=-200.0499;
t_ex_lo=200.0499;


// **********************************

while(1)
{
menu();
show_rtc();

update_interval();
 

coding for mplab

This code is for CCS...

Rafael
 

mplab int1

erm.. and i would like to ask is it ccs and mplab both oso can use for program the PIC??
And since both oso using source code.. then can the above code use in mplab? ...


beside that i oso wan to know SST is wat kind of software...
compare with mplab and ccs is it more nice???
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top