佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1319|回复: 4

AVR-GCC 的问题! 请帮帮忙!

[复制链接]
发表于 19-8-2008 03:34 PM | 显示全部楼层 |阅读模式
Below is not my sourcecode, just a reference for my project. My problem is how to add in library.
When i using AVR-GCC compiler, there is an error of no such directory/library.e.g. #include <Mega32.h>
How can i add in the #include <Mega32.h> library?
Or may be i should cut it to short, i have the compiling problem.
Anyone help me please. Thanks!

/*
This code contains all of our three state machines to run
the graphing calculator using a TV and two keypads.
This program is optimized for MEGA32 with 16MHz crystal.
Keypad one uses PORTA and keypad two uses PORTB
The TV uses PORTC. For debugging purposes, we have set up
PORTD to hyperterminal.
*/

//video gen and sound
//D.5 is sync:1000 ohm + diode to 75 ohm resistor
//D.6 is video:330 ohm + diode to 75 ohm resistor
//C.0 is sound

#pragma regalloc-    //I allocate the registers myself
#pragma optsize-     //optimize for speed

#include <Mega32.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <delay.h>
#include <string.h>

//cycles = 63.625 * 16 Note NTSC is 63.55
//but this line duration makes each frame exactly 1/60 sec
//which is nice for keeping a realtime clock
#define lineTime 1018

#define begin {
#define end   }
#define ScreenTop 30
#define ScreenBot 230
#define T0reload 256-60
#define width 126
#define maxkeys 16

// Different states of state machines
#define NoPush 30
#define MaybePush 31
#define Pushed 32
#define MaybeNoPush 33
#define recorded 34
#define init 35
#define parseA 36
#define Idle 37
#define clearScreen1 38
#define clearScreen2 39
#define clearScreen3 40
#define printTrig 41
#define BeginGraph 42
#define deleteOnScreen 43
#define paramInput 44
#define Graph 45
#define GraphInit1 46
#define GraphInit2 47
#define DoneGraph 48
#define parseB 49
#define calculateNow 50
#define GraphInit3 51


//Calculate logic
#define divide 13
#define multiply 14
#define subtract 15
#define add 16
#define sine 21
#define cosine 22
#define tangent 23
#define expon 24
#define pow 25
#define arcsin 26
#define arccos 27
#define arctan 28
#define ln 29

#define pi 3.1415926535
#define eConst 2.7182818284

//NOTE that v1 to v8 and i must be in registers!
register char v1 @4;
register char v2 @5;
register char v3 @6;
register char v4 @7;
register char v5 @8;
register char v6 @9;
register char v7 @10;
register char v8 @11;

register int i @12;

#pragma regalloc+

// Debugging
char instr[10], outstr[10];

// State machines Vars
char butnum1, butnum2, maybe;
unsigned char Statekey1, Statekey2, Statekey3, key;

// Input parsing
char Aarray[20], Barray[20], calculation[20], resultStr[20];
char oploc, xloc, yloc, text[15];

// Flags
int calc_done, graph_done, currentInp, precMode;

// Scientific vars
float result, A, B, powRes;

// Graphing vars
float inputA, inputB, inputC;
float xCoord, yCoord, xGraph, yGraph, xGraphold, yGraphold;
float xMin, xMax, yMin, yMax;
float  Binput, gran;
int lineGraph;
char graphCommand, input[6];

// Error checking inputs
char err, decErrCount, negErrCount, undefErr, boundErr, numEntry;

// Software timer and counters
char  t;
int time, k, j;

// TV
int LineCount;
char syncON, syncOFF;
char screen[1600];

// text stored to flash memory to minimize memory location
flash char cu1[]="SCIENTIFIC";
flash char cu2[]="GRAPHING";
flash char cu3[]="MODE";

flash char sinSign[]="SIN";
flash char cosSign[]="COS";
flash char tanSign[]="TAN";
flash char asinSign[]="ASIN";
flash char acosSign[]="ACOS";
flash char atanSign[]="ATAN";
flash char lnSign[]="LN";
flash char pollSin[] ="A SIN (BX+C)";
flash char pollCos[] ="A COS (BX+C)";
flash char pollTan[] ="A TAN (BX+C)";
flash char pollaSin[] ="A ASIN (BX+C)";
flash char pollaCos[] ="A ACOS (BX+C)";
flash char pollaTan[] ="A ATAN (BX+C)";
flash char pollLn[] = "A LN (BX)";
flash char pollPoly[] ="(AX+B)^C";
flash char pollexp[] ="A EXP^(BX)";
flash char pollA[]="A: ";
flash char pollB[]="B: ";
flash char pollC[]="C: ";

flash char dotMode[]="DOT ";
flash char lineMode[]="LINE";

flash char syntax[]="SYNTAX ERROR";
flash char undef[]="UNDEF";
flash char bigVal[]="INVALID ENTRY";

//Point plot lookup table
flash char pos[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
flash unsigned char keytbl[16]={0xee, 0xed, 0xeb, 0xe7, 0xde, 0xdd, 0xdb,
0xd7, 0xbe, 0xbd, 0xbb, 0xb7, 0x7e, 0x7d, 0x7b, 0x77};

// TV print lookup talbe
flash unsigned char numtblprint[17]={0, 49, 52, 55, 48, 50, 53, 56, 46, 51,
54, 57, 36, 47, 42, 45, 43};

// keypads look table according to allocated numbers for calculation
flash unsigned char numtblone[17]={0, 1, 4, 7, 0, 2, 5, 8, 10, 3, 6, 9, 11,
13, 14, 15, 16};
flash unsigned char numtbltwo[17]={0, 17, 21, 25, 29, 18, 22, 26, 30, 19,
23, 27, 31, 20, 24, 28, 32};


//===============================
//3x5 font numbers, then letters
//packed two per definition for fast
//copy to the screen at x-position divisible by 4
flash char smallbitmap[53][5]={
        //blank -0
        0b00000000,
        0b00000000,
        0b00000000,
        0b00000000,
        0b00000000,
        //sqrt  - 1
        0b00000000,
        0b00100010,
        0b00100010,
        0b10101010,
        0b01000100,
        //e  - 2
        0b11101110,
        0b10101010,
        0b11101110,
        0b10001000,
        0b11101110,
        //n  - 3
        0b00000000,
        0b00000000,
        0b11001100,
        0b10101010,
        0b10101010,
        //(-) -4
        0b00000000,
        0b00000000,
        0b01100110,
        0b00000000,
        0b00000000,
        //no need -5
        0b11101110,
        0b10101010,
        0b10101010,
        0b10101010,
        0b11101110,
        //no need -6
        0b11101110,
        0b10101010,
        0b10101010,
        0b10101010,
        0b11101110,
        //no need -7
        0b11101110,
        0b10101010,
        0b10101010,
        0b10101010,
        0b11101110,
        //( -8
        0b01000100,
        0b10001000,
        0b10001000,
        0b10001000,
        0b01000100,
        // ) -9
        0b01000100,
        0b00100010,
        0b00100010,
        0b00100010,
        0b01000100,
         //* - 10
        0b00000000,
        0b10101010,
        0b01000100,
        0b10101010,
        0b00000000,
        //+ - 11
        0b00000000,
        0b01000100,
        0b11101110,
        0b01000100,
        0b00000000,
        //^  - 12
        0b01000100,
        0b10101010,
        0b00000000,
        0b00000000,
        0b00000000,
        //- - 13
        0b00000000,
        0b00000000,
        0b11101110,
        0b00000000,
        0b00000000,
        //. -14
        0b00000000,
        0b00000000,
        0b00000000,
        0b00000000,
        0b01000100,
        //div - 15
        0b01000100,
        0b00000000,
        0b11101110,
        0b00000000,
        0b01000100,
        //0  - 16
        0b11101110,
        0b10101010,
        0b10101010,
        0b10101010,
        0b11101110,
        //1   -17
        0b01000100,
        0b11001100,
        0b01000100,
        0b01000100,
        0b11101110,
        //2  -18
        0b11101110,
        0b00100010,
        0b11101110,
        0b10001000,
        0b11101110,
        //3  -19
        0b11101110,
        0b00100010,
        0b11101110,
        0b00100010,
        0b11101110,

        };

//===============================
//Calling keypad1 routine
void call_keypad1(void)        {
        //get lower nibble
    DDRA = 0x0f;
        PORTA = 0xf0;
        delay_us(5);
        key = PINA;

        //get upper nibble
        DDRA = 0xf0;
        PORTA = 0x0f;
        delay_us(5);
        key = key | PINA;

        //find matching keycode in keytbl
        if (key != 0xff)  {
                for (butnum1=0; butnum1<maxkeys; butnum1++)        {
                        if (keytbl[butnum1]==key)  break;
                }
                if (butnum1==maxkeys) butnum1=0;
                else butnum1++; //adjust by one to make range 1-16
        }
        else butnum1=0;
} // end call_keypad

Its too long, i cut it.
If you all want to see more, i can post again.
回复

使用道具 举报


ADVERTISEMENT

发表于 20-8-2008 09:54 AM | 显示全部楼层

回复 1# teowcs84 的帖子

首先確定你有Mega32.h這個header file在你的directory裡面
回复

使用道具 举报

 楼主| 发表于 20-8-2008 02:29 PM | 显示全部楼层

回复 2# Squall_Chua 的帖子

只有 iom32.h
可不可以将 Mega32.h 改为 iom32.h ?
回复

使用道具 举报

发表于 21-8-2008 10:59 AM | 显示全部楼层
先确定 header 跟 library 的binary 都在。
回复

使用道具 举报

 楼主| 发表于 23-8-2008 02:33 AM | 显示全部楼层

回复 4# /dev/null 的帖子

#include <mega32.h> 我已经解决.

现在的问题是我compile le, error 是 '@'!
error message is :
../TcS.c:86: error: stray '@' in program
../TcS.c:86: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
'@' 代表什么?
//NOTE that v1 to v8 and i must be in registers!
register char v1 @4;
register char v2 @5;
register char v3 @6;
register char v4 @7;
register char v5 @8;
register char v6 @9;
register char v7 @10;
register char v8 @11;

register int i @12;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 24-12-2025 02:01 AM , Processed in 0.135184 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表