Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Check the CCS C program for errors

Status
Not open for further replies.

yousafzai82

Member level 4
Joined
Jan 20, 2010
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Pakistan
Activity points
1,844
Hi all..

I am using CCS C Compiler.. My code is given below. Please chech whether it will send AT commands correctly to send the ADC result..

#include<16F877.h>
#device ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,PUT
#use delay(clock=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)

#include<stdio.h>
#include<math.h>
#include<STDLIB.H>

//#include "C:\Program files\PICC\Devices\16f877.h"
#Byte PortA=0x05
#Byte PortB=0x06
#use fast_io(A)
#use fast_io(B)
#Define Nop #Asm Nop #EndAsm

int16 value;
float h,V,M;

void main(){
setup_adc( ADC_CLOCK_INTERNAL );
setup_adc_ports( ALL_ANALOG );
set_adc_channel(1);

while(1){
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);

value = read_adc();

h=0.0078201*value;
if(h<=4)
{
M=2*acos((4-h)/4);
V=10*(16*M/2-16*sin(M/2)+h*4*sin(M/2));
}
else
{
M=2*acos((h-4)/4);
V=10*(16*3.14159*(1-M/(2*3.14159))+h*4*sin(M/2)-16*sin(M/2));
}

send_SMS();

void send_SMS(void)
{
printf("AT\r\n");
delay_ms(5000);
printf("at+cmgf=1\r\n");
delay_ms(5000);
printf("at+cmgs=\"+4478XXXXXXXX\"\r\n");
delay_ms(5000);
printf("%f/n/r",(float)V);
putc(0x1A);
delay_ms(5000);
}

void main()
{
SET_TRIS_A( 0b10000110 );
SET_TRIS_B( 0b00000101 ); delay_ms(1);

send_SMS();

while(1)
{
// Toggle led
PORTA ^= 1;
// Simple delay
delay_ms(500);
}
}
}

I am getting the error messages
"Improper use of fucntion identifier" at line printf("AT\r\n");
and undefined identifier at line "send_SMS();"
 

HI,

Refer to the attachment.
 
#include<16F877.h>
#device ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,PUT
#use delay(clock=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)

#include<stdio.h>
#include<math.h>
#include<STDLIB.H>

//#include "C:\Program files\PICC\Devices\16f877.h"
#Byte PortA=0x05
#Byte PortB=0x06
#use fast_io(A)
#use fast_io(B)
#Define Nop #Asm Nop #EndAsm

int16 value;
float h,V,M;

void send_SMS(void)
{
printf("AT\r\n");
delay_ms(5000);
printf("at+cmgf=1\r\n");
delay_ms(5000);
printf("at+cmgs=\"+923469400983\"\r\n");
delay_ms(5000);
printf("%f/n/r",(float)V);
putc(0x1A);
delay_ms(5000);
}


void main(){


setup_adc( ADC_CLOCK_INTERNAL );
setup_adc_ports( ALL_ANALOG );
set_adc_channel(1);

SET_TRIS_A( 0b10000110 );
SET_TRIS_B( 0b00000101 ); delay_ms(1);


while(1){
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);
delay_ms( 30000);

value = read_adc();

h=0.0078201*value;
if(h<=4)
{
M=2*acos((4-h)/4);
V=10*(16*M/2-16*sin(M/2)+h*4*sin(M/2));
}
else
{
M=2*acos((h-4)/4);
V=10*(16*3.14159*(1-M/(2*3.14159))+h*4*sin(M/2)-16*sin(M/2));
}

send_SMS();

}
}

Now i am getting the error message Line94(0,1) Out of ROM, a segment or the program is too large sin.

Added after 2 hours 38 minutes:

Someone tell me how to use #separate functions or use some other means to remove the above error....
 

Hi,

I'm compile your code using my ccs compiler and got no error. Here i attached all the files including hex file generated using my ccs compiler.
 
I have checked but it is giving me the error messages again. May the version of CCS C i am using is limited version. I downloaded. Can you confirm that after i program the PIC with this code. Will it successfully send the value V on the said number??

I am working with the mcu for the first time so please help me with that.....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top