problem in mikroC PRO V2.50

General discussion on mikroC.
Post Reply
Author
Message
bobx
Posts: 115
Joined: 14 Mar 2010 08:35

problem in mikroC PRO V2.50

#1 Post by bobx » 08 May 2010 07:25

Hi.I write a program in mikroC PROV2.50 for my microcontroller(PIC 18F452) but I
faced to a problem that related only to C language and compiler give me the following error
messages;


A.(extern int adcvalmax[8]= {0,0,0,0,0,0,0,0};// 16 1504 Initialization of extern object 'adcvalmax' t1x.c //)in function;void Display_AdcX(int adcvalmax[8] )

B.(extern int adcvalmax[8]= {0,0,0,0,0,0,0,0};// 43 1504 Initialization of extern object 'adcvalmax' t1x.c//)in function; int MR_CHNS(int adcvalmax[8])

C.(return(adcvalmax);//77 1506 Implicit conversion of pointer to int t1x.c //)infunction; int MR_CHNS(int adcvalmax[8])

D.(LCD_Out(2,14,rp2val);// 96 1508 Implicit conversion of int to ptr t1x.c //)in function; void update_pwm(unsigned short int rp2val)

E.(184 365 Reentrancy is not allowed: function 'Lcd_Out' called from two threads __Lib_Lcd.c)
184 365 Reentrancy is not allowed: function 'Lcd_Out' called from two threads __Lib_Lcd.c
184 365 Reentrancy is not allowed: function 'Lcd_Out' called from two threads __Lib_Lcd.c
50 365 Reentrancy is not allowed: function 'Lcd_Chr_CP' called from two threads __Lib_Lcd.c
18 365 Reentrancy is not allowed: function 'Lcd_Cmd' called from two threads __Lib_Lcd.c


For the ease I attached the program and its error messages as a PDF file.

Here are the descriptions of my Functions and Main program;

1.int CHS_Read(int adcvalmax[8]); Reading input values by analog to digital module of the PIC18F452 and save the results in the array
" adcvalmax[m] ".

2.void Display_AdcX(int adcvalmax[8] ) ;get the array
" adcvalmax[m] "and by using it display its value on LCD.

3.In the Main program I call Function; " void Display_AdcX(int adcvalmax[8] ) " as; Display_AdcX( adcvalmax[] ); .

Would you please help me and tell me mistakes in my program?

Thanks,

My code of program and error messages;










int t4=0,index;
char *tc;
int adcvalmax[8]= {0,0,0,0,0,0,0,0};

#define stepsize 98
int interb0=0;


void Display_AdcX(int adcvalmax[8] ) {
int i=0,m=0;
char ch[8]= {0,0,0,0,0,0,0,0};
extern int adcvalmax[8]= {0,0,0,0,0,0,0,0};// 16 1504 Initialization of extern object 'adcvalmax' t1x.c //

for(i,m=0;i,m<8;i++,m++){ //IS THIS FOR STATEMENT RIGHT? ****************


ch = adcvalmax[m] /1000; //prepare value for display in A
Lcd_Chr(2, 1, 48 + ch); //write ASCII at 2nd row,1st column
Lcd_Chr_Cp('.');

ch = (adcvalmax[m] /100) % 10;
Lcd_Chr_Cp(48 + ch);

ch = (adcvalmax[m] /10) % 10;
Lcd_Chr_Cp(48 + ch);

ch = adcvalmax[m] % 10;
Lcd_Chr_Cp(48 + ch);
Lcd_Chr_Cp('A');

}

}//~


int MR_CHNS(int adcvalmax[8]){

long longadc=0;
extern int adcvalmax[8]= {0,0,0,0,0,0,0,0};// 43 1504 Initialization of extern object 'adcvalmax' t1x.c//
int ch[8]= {0,0,0,0,0,0,0,0};//declares a array of 8 integers
int m=0,i=0;
int Px=0,P1st=0,P2nd=0;


for(i=0;i<8;i++){

for(m=0;m<8;m++){

do{
ch=ADC_Read(i);
Px=ch;
}while(Px!=0);

P1st=ADC_Read(m);
Delay_ms(10);//10 ms pause
P2nd=ADC_Read(m);

while(P1st<=P2nd){
P1st=P2nd;
P2nd=0;
P2nd=ADC_Read(m);
}

adcvalmax[m] = P1st;// if (vf>vn)
index = (stepsize);
ADRESH = (ADRESH)&&(0b00000011);
longadc = ADRESH + ADRESL;
adcvalmax[m] = longadc * index;//in mA or mv

}
}

return(adcvalmax);//77 1506 Implicit conversion of pointer to int t1x.c //

}//~




void update_pwm(unsigned short int rp2val){

rp2val=0;

t4 = Adc_Read(4);
rp2val = ADRESL;


PWM1_Set_Duty(rp2val);//Set & change duty ratio due to the VRP2 value
//from 0 -255;(ADRESL)


LCD_Out(2,14,rp2val);// 96 1508 Implicit conversion of int to ptr t1x.c //

//(127: 50% duty ratio)
if(rp2val == 127) PORTC.F5=1;//Turn the LED on (RC5/pin24)

}//~



void interrupt() {

static int interb0;
//Turn off charger interrupt via INTO/RB0
INTCON.INT0IF=0;//Clear INT0(INTCON)external interrupt Flag bit to detect
//next inter.
interb0++;//interb0 = interb0+1

while(interb0 ==1){

PWM1_Stop();//Stop PWM


LCD_Cmd(_LCD_CLEAR);// send command to LCD (clear LCD)
tc = "STAND BY!";// assign a text to string
LCD_Out(1,1,tc);// print a string on LCD, 1st row, 1st column

PORTC.F3=1;//Turn the LED on (RC3/pin18):LED stand by state indicator
Delay_ms(1000);//One second pause
PORTC.F3=0;//Turn the LED off (RC3/pin18)
}

if(interb0!=1){
PWM1_Start();//Start PWM ,(interb0!=1)
interb0 = 0;
PORTC.F3=0;//Turn the LED off (RC3/pin18)
}

}//~




// LCD module connections
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections











void main() {



PORTA=0;//Clear port A
TRISA=0XFF;//Port A is input
PORTD=0;//Clear port D
TRISD=0;//Port D is output
PORTC=0;//Clear port C
TRISC=0;//port C is output
PORTB=0;//Clear port B
TRISB=0XFF;//port B is input
PORTE=0;//Clear port E
TRISE=0XFF;//Port E is input
TRISC = PORTC = 0;

INTCON.GIEH = 1; // When IPEN = 1,enables all high priority interrupts
INTCON.GIEL=1;//When IPEN = 1,enables all low priority peripheral interrupts
RCON.IPEN = 1;//Enable priority levels on interrupts
INTCON.INT0IE=1;//Enables the INT0 external interrupt
INTCON2.INTEDG0 = 0;// Interrupt on falling edge







LCD_Init();// initialize(4-bit interface connection)
LCD_Cmd(_LCD_CURSOR_OFF);// send command to LCD (cursor off)
LCD_Cmd(_LCD_CLEAR);// send command to LCD (clear LCD)
tc = "Hi!";// assign a text to string
LCD_Out(1,1,tc);// print a string on LCD, 1st row, 1st column



PWM1_Init(500);//500HZ but should Initialize PWM module at 50HZ ;
//using frequency divider with D-Flip_Flop IC.
PWM1_Set_Duty(127);//Set duty ratio to 50%



update_pwm(t4);
PWM1_Start();//Start PWM


//Not required to determine ADCON0;it is asked by uC compiler on NEW Project
// icon bar at the top at first automatically &done via:Adc_Read() Library

ADCON1=0x80;//configure VDD=Vref+,Vss=Vref-,8-analog channels&Right justified
//A/D Result Format
Delay_ms(2000);


MR_CHNS(adcvalmax);
Display_AdcX(adcvalmax);



}//~!






0 1 mikroCPIC1618.exe -MSF -DBG -pP18F452 -DL -O11111114 -fo8 -N"E:\T1\t1x.mcppi" -SP"E:\Bob's File\mikroC PRO PIC 2009 V2.50\MikroCProV2.50\defs\" -SP"E:\Bob's File\mikroC PRO PIC 2009 V2.50\MikroCProV2.50\uses\P18\" -SP"E:\T1\" "t1x.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_CType.mcl" "__Lib_CString.mcl" "__Lib_CStdlib.mcl" "__Lib_CMath.mcl" "__Lib_Conversions.mcl" "__Lib_Sprintf.mcl" "__Lib_PrintOut.mcl" "__Lib_Sprinti.mcl" "__Lib_Sprintl.mcl" "__Lib_Time.mcl" "__Lib_Trigonometry.mcl" "__Lib_Button.mcl" "__Lib_Keypad4x4.mcl" "__Lib_Manchester.mcl" "__Lib_OneWire.mcl" "__Lib_PS2.mcl" "__Lib_Sound.mcl" "__Lib_SoftI2C.mcl" "__Lib_SoftSPI.mcl" "__Lib_SoftUART.mcl" "__Lib_ADC_A_C.mcl" "__Lib_EEPROM_256.mcl" "__Lib_FLASH_w8_e64.mcl" "__Lib_I2C_c34.mcl" "__Lib_PWM_c21.mcl" "__Lib_SPI_c345.mcl" "__Lib_UART_c67.mcl" "__Lib_PortExpander.mcl" "__Lib_CANSPI.mcl" "__Lib_CF.mcl" "__Lib_CFFat16.mcl" "__Lib_GlcdFonts.mcl" "__Lib_Glcd.mcl" "__Lib_LcdConsts.mcl" "__Lib_Lcd.mcl" "__Lib_Mmc.mcl" "__Lib_MmcFat16.mcl" "__Lib_RS485.mcl" "__Lib_T6963C.mcl" "__Lib_SPIGlcd.mcl" "__Lib_SPILcd.mcl" "__Lib_SPILcd8.mcl" "__Lib_SPIT6963C.mcl" "__Lib_EthEnc28j60.mcl"
0 125 All files Preprocessed in 15 ms
0 121 Compilation Started t1x.c
16 1504 Initialization of extern object 'adcvalmax' t1x.c
43 1504 Initialization of extern object 'adcvalmax' t1x.c
77 1506 Implicit conversion of pointer to int t1x.c
96 1508 Implicit conversion of int to ptr t1x.c
223 122 Compiled Successfully t1x.c
0 126 All files Compiled in 172 ms
184 365 Reentrancy is not allowed: function 'Lcd_Out' called from two threads __Lib_Lcd.c
184 365 Reentrancy is not allowed: function 'Lcd_Out' called from two threads __Lib_Lcd.c
50 365 Reentrancy is not allowed: function 'Lcd_Chr_CP' called from two threads __Lib_Lcd.c
18 365 Reentrancy is not allowed: function 'Lcd_Cmd' called from two threads __Lib_Lcd.c
0 102 Finished (with errors): 08 May 2010, 09:47:28 t1x.mcppi
0 1 mikroCPIC1618.exe -MSF -DBG -pP18F452 -DL -O11111114 -fo8 -N"E:\T1\t1x.mcppi" -SP"E:\Bob's File\mikroC PRO PIC 2009 V2.50\MikroCProV2.50\defs\" -SP"E:\Bob's File\mikroC PRO PIC 2009 V2.50\MikroCProV2.50\uses\P18\" -SP"E:\T1\" "t1x.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_CType.mcl" "__Lib_CString.mcl" "__Lib_CStdlib.mcl" "__Lib_CMath.mcl" "__Lib_Conversions.mcl" "__Lib_Sprintf.mcl" "__Lib_PrintOut.mcl" "__Lib_Sprinti.mcl" "__Lib_Sprintl.mcl" "__Lib_Time.mcl" "__Lib_Trigonometry.mcl" "__Lib_Button.mcl" "__Lib_Keypad4x4.mcl" "__Lib_Manchester.mcl" "__Lib_OneWire.mcl" "__Lib_PS2.mcl" "__Lib_Sound.mcl" "__Lib_SoftI2C.mcl" "__Lib_SoftSPI.mcl" "__Lib_SoftUART.mcl" "__Lib_ADC_A_C.mcl" "__Lib_EEPROM_256.mcl" "__Lib_FLASH_w8_e64.mcl" "__Lib_I2C_c34.mcl" "__Lib_PWM_c21.mcl" "__Lib_SPI_c345.mcl" "__Lib_UART_c67.mcl" "__Lib_PortExpander.mcl" "__Lib_CANSPI.mcl" "__Lib_CF.mcl" "__Lib_CFFat16.mcl" "__Lib_GlcdFonts.mcl" "__Lib_Glcd.mcl" "__Lib_LcdConsts.mcl" "__Lib_Lcd.mcl" "__Lib_Mmc.mcl" "__Lib_MmcFat16.mcl" "__Lib_RS485.mcl" "__Lib_T6963C.mcl" "__Lib_SPIGlcd.mcl" "__Lib_SPILcd.mcl" "__Lib_SPILcd8.mcl" "__Lib_SPIT6963C.mcl" "__Lib_EthEnc28j60.mcl"
0 125 All files Preprocessed in 15 ms
0 121 Compilation Started t1x.c
16 1504 Initialization of extern object 'adcvalmax' t1x.c
43 1504 Initialization of extern object 'adcvalmax' t1x.c
77 1506 Implicit conversion of pointer to int t1x.c
96 1508 Implicit conversion of int to ptr t1x.c
223 122 Compiled Successfully t1x.c
0 126 All files Compiled in 172 ms
184 365 Reentrancy is not allowed: function 'Lcd_Out' called from two threads __Lib_Lcd.c
184 365 Reentrancy is not allowed: function 'Lcd_Out' called from two threads __Lib_Lcd.c
50 365 Reentrancy is not allowed: function 'Lcd_Chr_CP' called from two threads __Lib_Lcd.c
18 365 Reentrancy is not allowed: function 'Lcd_Cmd' called from two threads __Lib_Lcd.c
0 102 Finished (with errors): 08 May 2010, 09:47:28 t1x.mcppi

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: problem in mikroC PRO V2.50

#2 Post by tihomir.losic » 10 May 2010 10:58

Hello,

please, create your project, pack whole project folder, and send it to our Support Center:
http://www.mikroe.com/esupport/

Thanks.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

Post Reply

Return to “mikroC General”