Mplab c compiler

Veba

Üye
Katılım
9 May 2007
Mesajlar
15
Puanları
1
Yaş
40
//Main.h--------------------------------------------------------------------------------------------------------

#ifndef __MAIN_H
#define __MAIN_H

#include <p18f4550.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pwm.h> // PWM library functions
#include <delays.h> // Timer library functions
#include <usart.h> // USART library functions
#include <adc.h> // ADC library functions
#include <timers.h> // Timer library functions

//#include <portb.h>
//#include <string.h>

//---------------------------------------------------------------------
// Function Prototypes
//---------------------------------------------------------------------

#pragma code

void main (void);
void INITPic (void);
void InterruptHandlerLow(void);
void InterruptHandlerHigh(void);

//---------------------------------------------------------------------
//Config bits
//---------------------------------------------------------------------

#pragma config PLLDIV = 5, CPUDIV = OSC1_PLL2 ,USBDIV = 1
#pragma config FOSC = HSPLL_HS, FCMEN = OFF, IESO = OFF
#pragma config PWRT = ON, BOR = ON, BORV = 3, VREGEN = OFF
#pragma config WDT = OFF, WDTPS = 32768
#pragma config MCLRE = ON, LPT1OSC = OFF, PBADEN = OFF, CCP2MX = ON
#pragma config STVREN = ON, LVP = OFF, ICPRT = OFF, XINST = OFF, DEBUG = OFF
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
#pragma config CPB = OFF, CPD = OFF
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
#pragma config EBTRB = OFF

//---------------------------------------------------------------------
// Structures
//---------------------------------------------------------------------

//---------------------------------------------------------------------
//Constant Definitions
//---------------------------------------------------------------------

#define TRUE 1
#define FALSE 0

#define INIT_TRISC 0b10111011 // 1-input, 0-output
#define INIT_PORTC 0xFF

#define INIT_TRISD 0b11101100
#define INIT_PORTD 0xFF

#define INIT_TRISB 0b11111111
#define INIT_PORTB 0x00

#define LED_1 PORTDbits.RD0
#define LED_2 PORTDbits.RD1

#define PIC_TX PORTCbits.RC6
#define PIC_RX PORTCbits.RC7
#define PIC_RE PORTDbits.RD4

#define OSC_SPEED 20000000 // 20 MHz(PIC oscillator speed)
#define USART_BAUD 9600 // BaudRate
#define BRGH_HIGH 0

#define RXBUF_SIZE 32
#define TXBUF_SIZE 32
#define STRLENGHT 64 // lenght of data buffer

#endif // end #ifndef













//Main.c----------------------------------------------------------------------------------------------------------------


#include "main.h" // this file is in my directory
#include <p18f4550.h> // tihs file is in C compiler directory
#include <usart.h> // tihs file is in C compiler directory

//ram char serial[] ="please write the number of Leds How many you want to switch on : 0, 1 or 2";
//ram char serial2[]="Leds were switched off!";
//ram char serial3[]="please write the value of Leds intensity percent: 0% --> 100% and then press enter: ";
//ram char serial4[]="Warning!!! You should enter the value for percent: ";
//ram char serial5[]="%";
//ram char serial6[]="Press DEL for quit this programme in anytime";
//---------------------------------------------------------------------
// Interrupts
//---------------------------------------------------------------------
// High priority interrupt vector .....................................
#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
// Low priority interrupt vector ......................................
#pragma code InterruptVectorLow = 0x18
void InterruptVectorLow (void)
{
_asm
goto InterruptHandlerLow //jump to interrupt routine
_endasm
}
// Low priority interrupt routine .....................................
#pragma code
#pragma interrupt InterruptHandlerLow
void InterruptHandlerLow (void)
{
}
// High priority interrupt routine ....................................
#pragma code
#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh (void)
{
}
//----------------------------------------------------------------------------
// Init
//----------------------------------------------------------------------------
//#pragma code
void INITPic (void)
{
TRISD = INIT_TRISD;
PIC_RE=0;
PORTD=0x00;
}
//---------------------------------------------------------------------
// Main Program
//---------------------------------------------------------------------
//#pragma code

void main (void)
{
int i,j,k,m,x,t,y=0,a=0,percent=0;
signed int z[5];
INITPic();
OpenUSART( USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
129 );
//OpenTimer2(TIMER_INT_OFF & T2_PS_1_16& T2_POST_1_1 );
OpenPWM1(0xFF); //Configure the PWM Period 0xF0=50kHz

/*SetDCPWM1(0) for 0% initial duty cycle,
SetDCPWM1(512)for 50% initial duty cycle,
SetDCPWM1(1024)for100% initial duty cycle */

j=0x54;
k=0x55;

LED_1=1;
LED_2=1;
putrsUSART("Press DEL for quit this programme in anytime");

putrsUSART("please write the number of Leds How many you want to switch on : 0, 1 or 2: ");
while(ReadUSART()!= 0x7F) // Quit the programme (0x7F is ascii code for DEL)
{
if(DataRdyUSART())
{
x = ReadUSART();
if(x=='0')
{
PIC_RE=1;
WriteUSART( x );
PIC_RE=0;
putrsUSART("Leds were switched off!");
LED_1=0;
LED_2=0;
}
else if(x=='1')
{
PIC_RE=1;
WriteUSART( x );
for(i=0; i<1024; i++)
{
SetDCPWM1(i); //Set the duty-cycle 10bit
Delay10KTCYx(1);
if (i==1023)
{
PORTD=k;
k=~k;
}
}
PIC_RE=0;
putrsUSART("please write the value of Leds intensity percent: 0% --> 100% and then press enter: ");
while( a=0) // for checking the percent value
{
unsigned char cx;
cx=ReadUSART();
while(cx!=t) // t is ascii code number of "enter"
{
if( DataRdyUSART())
{
z[y]=ReadUSART();
y++;
if ( y>=4)
{
putrsUSART("Warning!!! You should enter the value for percent: ");
y=0; // for entering right percent value
a=0;
}
else if ( y<=3)
a=1; // entering is right
}
}
}
PIC_RE=1;
if ( z[2]!=-1) // calculation for the percent value
{
percent=100;
WriteUSART( percent );
}
else if ( z[2]=-1 && z[1]!=-1)
{
percent=((z[0]-30)*10) + ( z[1]-30);
WriteUSART( percent );
}
else if ( z[1]=-1 && z[0]!=-1)
{
percent=z[0]-30;
WriteUSART( percent );
}
PIC_RE=0;
putrsUSART("%");
m=percent*(1024/100); //calculate the duty-cycle
SetDCPWM1(m); //Set the duty-cycle 10bit
for(i=0; i<1024; i++)
{
SetDCPWM1(m); //Set the duty-cycle 10bit
Delay10KTCYx(1);
if (i==1022)
{
PORTD=k;
k=~k;
i=0;
}
}
}
else if(x=='2')
{
PIC_RE=1;
WriteUSART( x );
for(i=0; i<1024; i++)
{
SetDCPWM1(i); //Set the duty-cycle 10bit
Delay10KTCYx(1);
if (i==1023)
{
PORTD=j;
j=~j;
}
}
PIC_RE=0;
putrsUSART("please write the value of Leds intensity percent: 0% --> 100% and then press enter: ");
while( a=0) // for checking the percent value
{
unsigned char cx;
cx=ReadUSART();
while( cx!=t) // t is ascii code number of "enter"
{
if( DataRdyUSART())
{
z[y]=ReadUSART();
y++;
if ( y>=4)
{
putrsUSART("Warning!!! You should enter the value for percent: ");
y=0; // for entering right percent value
a=0;
}
else if ( y<=3)
a=1; // entering is right
}
}
}
PIC_RE=1;
if ( z[2]!=-1) // calculation for the percent value
{
percent=100;
WriteUSART( percent );
}
else if ( z[2]=-1 && z[1]!=-1)
{
percent=((z[0]-30)*10) + ( z[1]-30);
WriteUSART( percent );
}
else if ( z[1]=-1 && z[0]!=-1)
{
percent=z[0]-30;
WriteUSART( percent );
}
PIC_RE=0;
putrsUSART("%");
m=percent*(1024/100); //calculate the duty-cycle
SetDCPWM1(m); //Set the duty-cycle 10bit
for(i=0; i<1024; i++)
{
SetDCPWM1(m); //Set the duty-cycle 10bit
Delay10KTCYx(1);
if (i==1022)
{
PORTD=j;
j=~j;
i=0;
}
}
}
PIC_RE=0;
}
}
}



Arkadaşlar yukarıdaki programı 184550 için derlemeye çalışıyorum,fakat bir türlü başaramadı.Kodlarda bir hata yok fakat derleyemiyorum.Hi-tech universal tool suite,mplab c compiler (select tool language) bu ikisini denedim yine derlemiyor.Yardımcı olursanız sevinirim.
 
Yazılım hi-tech C gibi duruyor. Siz hangi hatayı aldınız onu da yazarsanız daha sağlıklı cevap verebilirim.
Örneğin Hitech derleyiciniz 18F serisini destekliyor mu?
 
Ben hi tech yazılımını da indirdim.18fxxx destekliyor.Hatta yüklerken 18f4550'yi de gördüm.

Build C:\Documents and Settings\ert\Desktop\mpa\aoi projesi for device 18F4550
Using driver C:\Program Files\HI-TECH Software\PICC-18\PRO\9.63\bin\picc18.exe

Make: The target "C:\Documents and Settings\ert\Desktop\mpa\se.p1" is out of date.
Executing: "C:\Program Files\HI-TECH Software\PICC-18\PRO\9.63\bin\picc18.exe" -C "C:\Documents and Settings\ert\Desktop\mpa\se.asm" -q --chip=18F4550 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [141] C:\Documents and Settings\ert\Desktop\mpa\se.asm; 6.21 can't open include file "p18f4550.h": No such file or directory
Error [141] ; . can't open object file "se.obj": No such file or directory

********** Build failed! **********

Aldığım hata bu.Sanıyorum kütüphaneyi bulamıyor.Kullandığım tool suite ise
active tool suite=> HI-TECH Universal Toolsuite
Toolsuite contents=>HI-TECH ANSI C Compiler(sadece bu içerik var başka yok)
 
Eğer picc-18 yüklü ise ve mplab ile doğru entegre edilmişse bu hatayı almamanız gerekir.Ya picc18 doğru şekilde yüklenmemiş, ya da doğru tanıtılmamış olmalı. Projeyi açtıktan sonra project>set language tool locations penceresini açın, orada yüklemiş olduğunuz c18 derleyicinizi işaret edin.
 
Birde şöyle birşey deneyebilirsiniz. Projenizi c:\mpa gibi bir kök dizine taşıyın, bir daha derlemeyi deneyin. Hitech'in eski bir sürümünde böyle bir hata ile karşılaştığımı hatırlıyorum.
 
Birçok toolsuite var.Ben hı -tech tool suite kullandım ve sorun ortaya çıktı.Dediğiniz gibi kök dosyalarından kaynaklı bir sorun olabilir deneyeyim.Teşekkür ederim.Bir de elinde imkan olan yani 18f4550'yi destekleyen mplam toolsuite'i ile bir arkadaş derlemeye çalışırsa sevinirim.Belki basit bir yerde hata yapıyorumdur.

C:/ mpa denedim sonuç olumsuz maalesef.
aldığım hata mesajı:Build C:\mpa\rty for device 18F4550
Using driver C:\Program Files\HI-TECH Software\PICC-18\PRO\9.63\bin\picc18.exe

Make: The target "C:\mpa\led.p1" is out of date.
Executing: "C:\Program Files\HI-TECH Software\PICC-18\PRO\9.63\bin\picc18.exe" -C C:\mpa\led.asm -q --chip=18F4550 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [141] C:\mpa\led.asm; 6.21 can't open include file "p18f4550.h": No such file or directory
Error [141] ; . can't open object file "led.obj": No such file or directory

********** Build failed! **********
 
Kodunuzun bulunduğu klasöre (örneğin C:\mpa) bakar mısınız .cce uzantılı bir dosya var mı? Varsa bu dosyayı notepad ile açın.
 

Forum istatistikleri

Konular
129,465
Mesajlar
927,124
Kullanıcılar
452,026
Son üye
bodos38

Yeni konular

Geri
Üst