Hallo
Die komplette Ausgabe der Fehlermeldungen wäre sinnvoll. Vermutlich wurde RP6ControlLib.c nicht in das Projekt eingebunden und deshalb kennt der Kompiler die Funktion initRP6Control(); nicht.
Bist du sicher, dass du das so machen willst? "TIMSK |= (1 << TOIE1);" funktioniert mit dem RP6, weil seine Library den Timer1 zur Motoransteuerung nutzt und der Timer deshalb auch schon richtig initialisiert wurde.
Init vom m32:
Code:
void initRP6Control(void)
{
portInit(); // Setup port directions and initial values.
// This is the most important step!
cli(); // Disable global interrupts.
// UART:
UBRRH = UBRR_BAUD_LOW >> 8; // Setup UART: Baud is Low Speed
UBRRL = (uint8_t) UBRR_BAUD_LOW;
UCSRA = 0x00;
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
UCSRB = (1 << TXEN) | (1 << RXEN) | (1 << RXCIE);
// Initialize ADC:
ADMUX = 0; //external reference
ADCSRA = (0<<ADIE) | (0<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADIF);
SFIOR = 0;
// Initialize External interrupts - all disabled:
MCUCR = (1 << ISC11) | (1 << ISC10) | (1 << ISC01) | (1 << ISC00);
GICR = (0 << INT2) | (0 << INT1) | (0 << INT0);
MCUCSR = (0 << ISC2);
// 10kHz Timer 0:
TCCR0 = (0 << WGM00)
| (1 << WGM01)
| (0 << COM00)
| (0 << COM01)
| (0 << CS02)
| (1 << CS01)
| (0 << CS00);
OCR0 = 199;
/*
Timer 1 is free for your application!
*/
// Timer 2 - used for beeper:
TCCR2 = 0;
OCR2 = 0xFF;
// Enable timer interrupts:
TIMSK = (1 << OCIE0);
// SPI Master (SPI Mode 0, SCK Frequency is F_CPU/2, which means it is 8MHz
// on the RP6 CONTROL M32...):
SPCR = (0<<SPIE)
| (1<<SPE)
| (1<<MSTR)
| (0<<SPR0)
| (0<<SPR1)
| (0<<CPOL)
| (0<<CPHA);
SPSR = (1<<SPI2X);
sei(); // Enable Global Interrupts
}
(Aus RP6ControlLib.c)
Init vom RP6:
Code:
void initRobotBase(void)
{
portInit(); // Setup port directions and initial values.
// THIS IS THE MOST IMPORTANT STEP!
cli(); // Disable global interrupts
enableResetButton(); // Make sure the Reset Button is enabled!
// Do not disable it if you want to be able to
// reset your robot! (Otherwise you can only
// stop it by switching it off completely,
// if it gets out of control ;) )
IRCOMM_OFF(); // Make sure that IRCOMM and ...
setACSPwrOff(); // ACS are turned OFF!
// UART:
UBRRH = UBRR_BAUD_LOW >> 8; // Setup UART: Baudrate is Low Speed
UBRRL = (uint8_t) UBRR_BAUD_LOW;
UCSRA = 0x00;
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
UCSRB = (1 << TXEN) | (1 << RXEN) | (1 << RXCIE);
// Initialize ADC:
ADMUX = 0; //external reference
ADCSRA = (0<<ADIE) | (0<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADIF);
SFIOR = 0;
// Initialize External interrupts:
MCUCR = (0 << ISC11) | (1 << ISC10) | (0 << ISC01) | (1 << ISC00);
GICR = (1 << INT2) | (1 << INT1) | (1 << INT0);
MCUCSR = (0 << ISC2);
// Initialize Timer 0 - 100µs cycle for Delays/Stopwatches, RC5 reception etc.:
TCCR0 = (0 << WGM00) | (1 << WGM01)
| (0 << COM00) | (0 << COM01)
| (0 << CS02) | (1 << CS01) | (0 << CS00);
OCR0 = 99;
// Initialize Timer1 - PWM:
// PWM, phase correct with ICR1 as top value.
TCCR1A = (0 << WGM10) | (1 << WGM11) | (1 << COM1A1) | (1 << COM1B1);
TCCR1B = (1 << WGM13) | (0 << WGM12) | (1 << CS10);
ICR1 = 210; // Phase corret PWM top value - 210 results in
// about 19 kHz PWM.
// ICR1 is the maximum (=100% duty cycle) PWM value!
// This means that the PWM resolution is a bit lower, but
// if the frequency is lower than 19 kHz you may hear very
// annoying high pitch noises from the motors!
// 19 kHz is a bit over the maximum frequency most people can
// hear!
//
// ATTENTION: Max PWM value is 210 and NOT 255 !!!
OCR1AL = 0;
OCR1BL = 0;
setMotorDir(FWD,FWD); // Direction Forwards
// Initialize Timer2 - ACS:
TCCR2 = (1 << WGM21) | (0 << COM20) | (1 << CS20);
OCR2 = 0x6E; // 0x6E = 72kHz @8MHz
// Initialize Timer Interrupts:
TIMSK = (1 << OCIE0); //| (1 << OCIE2); // Fixed: Timer2 Interrupt is turned
// off by default now! It is only active
// when ACS/IRCOMM are transmitting.
// Initialize ACS:
sysStatACS.channel = ACS_CHANNEL_RIGHT;
acs_state = ACS_STATE_IRCOMM_DELAY;
sei(); // Enable Global Interrupts
}
(Aus RP6RobotBaseLib.c)
Gruß
mic
Lesezeichen