예제 #1
0
void Motor_save_PID_settings()
{
  char checksum;
  checksum = (char)drive.Kp + drive.Ki + drive.Kd;
  eeprom_Write( MOTOR_EEPROM, (char)drive.Kp );
  eeprom_Write( MOTOR_EEPROM+1, (char)drive.Ki );
  eeprom_Write( MOTOR_EEPROM+2, (char)drive.Kd );
  eeprom_Write( MOTOR_EEPROM+3, checksum );
  
}
예제 #2
0
int
main (void)
{
	uint8_t ret, b, x;
	uint8_t ee[2];
	
	// Set clock to full speed
	CLKPR = 0x80;
	CLKPR = 0x00;

	// Init timer
	Timer0Initialise ();
	
	usart_Init(12);
	usart_TxQueuePutStr("\n\r"
			      "UART test\n\r"
			      "-----------------\n\r");


	interrupt_Enable(1);
	b = 5;
 
	while (1) {
		ret = usart_Receive(&x);
		if(ret){
			usart_TxQueuePut('*');
			b = x;
			ee[0] = b;
			ee[1] = ~b;
			eeprom_Write(66,ee,2);
			ee[0] = ee[1] = 0;
			
		}
		eeprom_Read(66,ee,2);
		usart_TxQueuePutDec(b);
		usart_TxQueuePutHex(b);
		usart_TxQueuePut('!');
		usart_TxQueuePutHex(ee[0]);
		usart_TxQueuePutHex(ee[1]);
		usart_TxQueuePutStr("\n\r");
		WaitMilliseconds(500);		


	}
}