Ejemplo n.º 1
0
/*;receive a 8-U8_T data from 24Cxx*/
U8_T sI2C_read( void )
{
	U8_T i, data1 = 0;

	for( i=0; i<8; i++ )
	{
		I2C_SCL = 1;
		data1 = ( data1 << 1 ) | I2C_SDA;
		I2C_SCL = 0;
		DELAY_Us(1);  // this is to slow down all i2c communication so that the pic chip 
					  // is able to run better. MDF 12/01/04
	}  
	return data1;
}
Ejemplo n.º 2
0
// 1ms 
void PWMoutput(void)
{
	U16_T far temp_relay = 0;
	if(WriteFlash == 1)   return;

	if(flag_PWM == STABLE)  // 
	{
		Wakeup_Count++;
		if(Wakeup_Count > 200)
		{
			flag_PWM = PWM;
			PWM_inverse = 0;
		}
		RELAY1_8 = (U8_T)new_output;
		DELAY_Us(5);
	  	RELAY_LATCH = 0; 
		RELAY_LATCH = 1;  		
		DI2_LATCH = 1;
		KEY_LATCH = 1;
		DI1_LATCH = 1;

		if( new_output & 0x100)
			RELAY_9 = 0;
		else 
			RELAY_9 = 1;
	
		/* OUTPUT10  */
		if( new_output & 0x0200)
			RELAY_10 = 0;
		else 
			RELAY_10 = 1;
		
	}
	else  if(flag_PWM == PWM)
	{
	//	Test[41] = new_output;
		if(PWM_inverse == 1 )  
		{ 
			PWM_inverse = 0;  
			temp_relay =  new_output;
		}
		else if(PWM_inverse == 0) 
		{
			PWM_inverse = 1;
			temp_relay = 0;
		}
	/*	if(PWM_inverse < 1 ) 
		{
			PWM_inverse++;  
			temp_relay = DO_Value;
			
		}
		else
		{
		 	PWM_inverse = 0;
			temp_relay =  0;
		} */
//		Test[46] = temp_relay;
		RELAY1_8 = (U8_T)temp_relay;		
		DELAY_Us(5);
	  	RELAY_LATCH = 0; 		
		RELAY_LATCH = 1; 
		DI2_LATCH = 1;
		KEY_LATCH = 1;
		DI1_LATCH = 1;

		if( temp_relay & 0x100)
			RELAY_9 = 0;
		else 
			RELAY_9 = 1;
	
		/* OUTPUT10  */
		if( temp_relay & 0x0200)
			RELAY_10 = 0;
		else 
			RELAY_10 = 1;

	} 

}