Beispiel #1
0
/******************************************************************************
 * Function:        void InitTempSensor(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Initializes SPI interface & chip select line
 *
 * Note:            None
 *****************************************************************************/
void InitTempSensor(void)
{
    #if defined(PICDEM_FS_USB)
    cs_temp_sensor = 1;
    tris_cs_temp_sensor = OUTPUT_PIN;
    OpenSPI(SPI_FOSC_64, MODE_11, SMPMID);
    
    // Initialize readable values - default to room temperature
    temperature.Val = 0x0C87;       // 25 degree celsius
    UpdateCelsiusASCII();

	#elif defined(PIC18F87J50_PIM)
    temperature.Val = 0x0C87;       // 25 degree celsius
    UpdateCelsiusASCII();

	//Need to initialize I2C Module to prepare for communication with
	//TC74 temperature sensor on the HPC Explorer board.
	mInitI2CPins();				// See io_cfg.h
	SSP1STAT = 0xC0;			// Slew rate control disabled, SMBus
	SSP1CON1 = 0x08;			// I2C Master mode
	SSP1CON2 = 0x00;
	SSP1ADD = 0x7D;				// Just under 100kHz at 48MHz core frequency
	SSP1CON1bits.SSPEN = 1;		// Enable MSSP module	

	I2CStateVariable = 0;		// Initial state for I2C state machine

    #endif    
}//end InitTempSensor
Beispiel #2
0
/******************************************************************************
 * Function:        void InitTempSensor(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Initializes SPI interface & chip select line
 *
 * Note:            None
 *****************************************************************************/
void InitTempSensor(void)
{
    cs_temp_sensor = 1;
    tris_cs_temp_sensor = OUTPUT_PIN;
	OpenSPI(SPI_FOSC_64, MODE_11, SMPMID);
    
    // Initialize readable values - default to room temperature
    temperature._word = 0x0C87;       // 25 degree celsius
    UpdateCelsiusASCII();
    
}//end InitTempSensor