void Motor_read_PID_settings() { char v1,v2,v3,checksum; v1 = eeprom_Read( MOTOR_EEPROM ); v2 = eeprom_Read( MOTOR_EEPROM+1 ); v3 = eeprom_Read( MOTOR_EEPROM+2 ); checksum = eeprom_Read( MOTOR_EEPROM+3 ); putstr("Init Drive PID"); if ((v1 + v2 + v3) == checksum) { // checksum is OK - load values into motor control block drive.Kp = v1; drive.Ki = v2; drive.Kd = v3; } else putstr(" no cksum, defaults"); putstr("\r\n"); }
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); } }