Hi, I got error in send_string(lala):

how to fix it ? thnaks ...

#include <p24Hxxxx.h>
#include <libpic30.h>
#include <stdio.h>

 int FBS __attribute__((space(prog), address(0xF80000))) = 0xCF ;
//_FBS(
//    BWRP_WRPROTECT_OFF & // Boot Segment Write Protect (Boot Segment may be written)
//    BSS_NO_FLASH &       // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
//    RBS_NO_RAM           // Boot Segment RAM Protection (No Boot RAM)
//);
 int FSS __attribute__((space(prog), address(0xF80002))) = 0xCF ;
//_FSS(
//    SWRP_WRPROTECT_OFF & // Secure Segment Program Write Protect (Secure segment may be written)
//    SSS_NO_FLASH &       // Secure Segment Program Flash Code Protection (No Secure Segment)
//    RSS_NO_RAM           // Secure Segment Data RAM Protection (No Secure RAM)
//);
 int FGS __attribute__((space(prog), address(0xF80004))) = 0x7 ;
//_FGS(
//    GWRP_OFF &           // General Code Segment Write Protect (User program memory is not write-protected)
//    GSS_OFF              // General Segment Code Protection (User program memory is not code-protected)
//);
 int FOSCSEL __attribute__((space(prog), address(0xF80006))) = 0x20 ;
//_FOSCSEL(
//    FNOSC_FRC &          // Oscillator Mode (Internal Fast RC (FRC))
//    IESO_OFF             // Two-speed Oscillator Start-Up Enable (Start up with user-selected oscillator)
//);
 int FOSC __attribute__((space(prog), address(0xF80008))) = 0xC7 ;
//_FOSC(
//    POSCMD_NONE &        // Primary Oscillator Source (Primary Oscillator Disabled)
//    OSCIOFNC_OFF &       // OSC2 Pin Function (OSC2 pin has clock out function)
//    FCKSM_CSDCMD         // Clock Switching and Monitor (Both Clock Switching and Fail-Safe Clock Monitor are disabled)
//);
 int FWDT __attribute__((space(prog), address(0xF8000A))) = 0x5F ;
//_FWDT(
//    WDTPOST_PS32768 &    // Watchdog Timer Postscaler (1:32,768)
//    WDTPRE_PR128 &       // WDT Prescaler (1:128)
//    WINDIS_OFF &         // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
//    FWDTEN_OFF           // Watchdog Timer Enable (Watchdog timer enabled/disabled by user software)
//);
 int FPOR __attribute__((space(prog), address(0xF8000C))) = 0xE7 ;
//_FPOR(
//    FPWRT_PWR128         // POR Timer Value (128ms)
//);
 int FICD __attribute__((space(prog), address(0xF8000E))) = 0xC3 ;
//_FICD(
//    ICS_PGD1 &           // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
//    JTAGEN_OFF           // JTAG Port Enable (JTAG is Disabled)
//);

 int main (){

             // Initilize ADC
             // AN0 & AN11 as input
             AD1PCFGL = 0; //an0-an15
             //AD1PCFGH = 0xF000;//AN16-AN32
             AD1CON1bits.AD12B = 0;//set 1 for 12bit adc, 0 for 10bit adc
             //format integer
             AD1CON1bits.FORM = 0;//integer
             AD1CON1bits.SSRC = 0;//clear sample bit ends sampling and start conversion

             AD1CON2bits.VCFG = 0;// avss avdd

             AD1CON3bits.SAMC =1;// 1*TAD
             AD1CON3bits.ADCS = 0;//tcy=tad

             // initilize uart
             TRISFbits.TRISF6 = 0;   //DE as output
             TRISDbits.TRISD9 = 0;   //RE as output

             LATFbits.LATF6 = 0;     //tx disable
             LATDbits.LATD9 = 0;     //rx enalble

             //uart initilize
             U1MODEbits.STSEL = 0;   //one stop bit
             U1MODEbits.PDSEL = 0;   //8bit data, noparity
             U1MODEbits.ABAUD = 0;   //baudrate measurement
             U1MODEbits.BRGH = 0;    //low speed//9600,19200

             U1BRG = 23;             //(fcy / 16 baudrate) -1

             U1MODEbits.UARTEN = 1;  //UART  enable
             U1STAbits.UTXEN = 1  ;  // transmit enable

//             int a = 0       ;
             int result1 = 0  ;
             int result2 = 0  ;
             int result3 = 0  ;
             int result4 = 0  ;

             unsigned char lala[2000];

     while(1);{
//                  for( a = 10; a < 20; a = a + 1 )
//                  {
//                      AD1CHS0bits.CH0SA = a ;  //select which ANI connect to channel 0
//                      AD1CHS0bits.CH0NA = 0 ;  //vref as channel 0 -ve input
//                      AD1CON1bits.ADON  = 1 ;
//                      AD1CON1bits.SAMP = 1  ;
//                      __delay32(50)         ;
//                      AD1CON1bits.SAMP = 0  ;   //sampling bit to 0
//                      while(!AD1CON1bits.DONE);
//                      result = ADC1BUF0     ;
//                  }

                      //AI01
                      AD1CHS0bits.CH0SA = 0  ;  //select which ANI connect to channel 0
                      AD1CHS0bits.CH0NA = 0  ;  //vref as channel 0 -ve input
                      AD1CON1bits.ADON  = 1  ;
                      AD1CON1bits.SAMP = 1   ;
                      __delay32(50)          ;
                      AD1CON1bits.SAMP = 0   ;   //sampling bit to 0
                      while(!AD1CON1bits.DONE);
                      result1 = ADC1BUF0      ;

                      //AI02
                      AD1CHS0bits.CH0SA = 1  ;  //select which ANI connect to channel 0
                      AD1CHS0bits.CH0NA = 0  ;  //vref as channel 0 -ve input
                      AD1CON1bits.ADON  = 1  ;
                      AD1CON1bits.SAMP = 1   ;
                      __delay32(50)          ;
                      AD1CON1bits.SAMP = 0   ;   //sampling bit to 0
                      while(!AD1CON1bits.DONE);
                      result2 = ADC1BUF0      ;

                      //AI03
                      AD1CHS0bits.CH0SA = 2  ;  //select which ANI connect to channel 0
                      AD1CHS0bits.CH0NA = 0  ;  //vref as channel 0 -ve input
                      AD1CON1bits.ADON  = 1  ;
                      AD1CON1bits.SAMP = 1   ;
                      __delay32(50)          ;
                      AD1CON1bits.SAMP = 0   ;   //sampling bit to 0
                      while(!AD1CON1bits.DONE);
                      result3 = ADC1BUF0      ;

                      //AI04
                      AD1CHS0bits.CH0SA = 3   ;  //select which ANI connect to channel 0
                      AD1CHS0bits.CH0NA = 0   ;  //vref as channel 0 -ve input
                      AD1CON1bits.ADON  = 1   ;
                      AD1CON1bits.SAMP = 1    ;
                      __delay32(50)           ;
                      AD1CON1bits.SAMP = 0    ;   //sampling bit to 0
                      while(!AD1CON1bits.DONE);
                      result4 = ADC1BUF0      ;

                     sprintf(lala,"value of a: %d %d %d %d\n",result1,result2,result3,result4); 
                     send_string(lala);
                     __delay32(20000);

            }
  1. send_string() is not a standard C function unless this is a Windows system, in which case I don't know about it.
  2. Obviously you are trying to control a PIC and UART(s). Most of your code are either defined elsewhere, are macros, or who knows. IE, there is not enough information to help you.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.