Fehlermeldung avr-gcc

#4077517
Lesenswert?

Ein Programm enthält ua. Variablen:

TCCR0 = [...]
  OCR0 = [...]
  TIMSK |= 1<<OCIE0;

die WinAVR-Umgebung kann das nicht auflösen, gibt Fehlr aus ' could not 
resolve symbols...


Beim Build wird ausgegeben: "avr-gcc Anwendungsfahler. Die Anwendung 
konnte nicht gestartet werden. Fehler 0xc0000142.

Was bedeutet das und was muss ich tun, um das abzustellen?

Gruss + Frohe Ostern

Robert
#4077576
Lesenswert?

Die Fehlermeldung von eclipse besagt: 'could not resolve symbol...' dann 
folgt der Name, hier TCCR0, OCR0, TIMSK, OCIEO. Weitere register werden 
nicht angesprochen. Das Original der Funktion ist das von P.Dannegger, 
es kann hier im Forum geladen werden. Die main ist von mir und kann hier 
nicht geladen werden.

--------8<---------------------------8<-------------------8<-----
#include "C:\Users\RFr\Libs\avrlib\lcd.h"
#include "C:\Users\RFr\Libs\avrlib\encoder.h"

#include <avr/io.h>
#include <avr/interrupt.h>



#include "Drehgeber.c"
#include "NCO.h"
#include "NCO_conf.h"


void main(){
    }


/*
 * Drehgeber.c
 *
 *  Created on: 02.04.2015
 *      Author:
 */


/*********************************************************************** 
*/
/* 
*/
/*                      Reading rotary encoder                      */
/*                      one, two and four step encoders supported   */
/* 
*/
/*              Author: Peter Dannegger 
*/
/* 
*/
/*********************************************************************** 
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include "NCO_conf.h"

                // target: ATmega16
//---------------------------------------------------------------------- 
--

#define XTAL        8e6         // 8MHz


volatile int8_t enc_delta;          // -128 ... 127
static int8_t last;


void encode_init( void )
{
  int8_t new;
  new = 0;

  if( Phase_A )    new = 3;
  if( Phase_B )    new ^= 1;                    // convert gray to 
binary

  last = new;                           // power on state
  enc_delta = 0;
  /*********************************************************************** 
*******************
  hier tritt der Fehler auf

  TCCR0 = 1<<WGM01^1<<CS01^1<<CS00;         // CTC, XTAL / 64
  OCR0 = (uint8_t)(XTAL / 64.0 * 1e-3 - 0.5);   // 1ms
  TIMSK |= 1<<OCIE0;

  Bis hierhin.
  ************************************************************************ 
*******************/
}


ISR( TIMER0_COMP_vect )             // 1ms for manual movement
{
  int8_t new, diff;

  new = 0;
  if( Phase_A )
    new = 3;
  if( Phase_B )
    new ^= 1;                   // convert gray to binary
  diff = last - new;                // difference last - new
  if( diff & 1 ){               // bit 0 = value (1)
    last = new;                 // store new as next last
    enc_delta += (diff & 2) - 1;        // bit 1 = direction (+/-)
  }
}


int8_t encode_read1( void )         // read single step encoders
{
  int8_t val;

  cli();
  val = enc_delta;
  enc_delta = 0;
  sei();
  return val;                   // counts since last call
}


int8_t encode_read2( void )         // read two step encoders
{
  int8_t val;

  cli();
  val = enc_delta;
  enc_delta = val & 1;
  sei();
  return val >> 1;
}


int8_t encode_read4( void )         // read four step encoders
{
  int8_t val;

  cli();
  val = enc_delta;
  enc_delta = val & 3;
  sei();
  return val >> 2;
}


int main( void )
{
  int32_t val = 0;
  encode_init();
  sei();

  for(;;){
    val += encode_read1();          // read a single step encoder
   }
}
Gast #4077945
Lesenswert?

M328 hat einfach "modernere" Timer.
Timer0 hat z.B. zwei CompareMatchs-Register:
OCR0A und OCR0B. Als max Wert für CTC-Mode wird OCR0A benutzt.

TIMSK existiert nicht (weil nicht mehr alle IntEnableBits aller Timer in 
ein Register passen würde, hat jeder Timer sein eigenes), aber TIMSK0.
Zufiele "zuviele Bits"-Problem existiert auch beim TCCR(0). Es gibt 
TCCR0A und TCCR0B, auf die die diversen Bits verteilt sind.

Leider ist noch einiger Code für die "alten" AVRs im Umlauf :-(

BTW, vor kurzem hab ich mir das C++ Framework Mcucpp von Konstantin 
Chizhov angeschaut. Nicht trivial in der Benutzung, aber genau solche 
Dinge, wie hier passiert, sind damit aus der Welt. Die Template Klassen, 
die Timer kapseln, kümmern sich um die Löw-Level Details. Und ergeben 
Code, der sich nicht von "einfach hingeschrieben" unterscheidet.
1
#include <avr/interrupt.h>
2

3
#include <timers.h>
4
#include <iopins.h>
5

6
using namespace Mcucpp;
7
using namespace Timers;
8
typedef IO::Pb0 Led;
9

10
ISR(SIG_OVERFLOW0)
11
{
12
  Led::Toggle();
13
}
14

15
int main()
16
{
17
  Led::SetConfiguration(Led::Port::Out);
18
  Timer0::Start(Timer0::Div1);
19
  Timer0::EnableInterrupt();
20
  sei();
21

22
  while(1) {}
23
  return 0;
24
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren