• AVR Freaks

Helpful ReplyHot!UART PROBLEM

Page: 12 > Showing page 1 of 2
Author
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
2019/08/12 23:27:30 (permalink)
0

UART PROBLEM

Hi everyone i am working with PIC24F04KA200 to display temperature  using uart. I have tried with many different ways but i couldn't able do it. So its time to ask help,i have written code for temperature sensor(ds18b20) in PIC24F04KA200 and its works fine its sensing temperature but i need to read temperature what ever it sensing for this i have used uart, first i have set uart configuration and i have checked with sending some character to uart its worked in monitor it displayed characters. Now the question is how display my computed temperature for this i have been working from last one week but i couldn't. For the first time i am using uart .Please kindly help me.
here is my code

 
void uart_init(void)
{
// UART_SETUP
U1BRG = 25; //Baud rate set to 9600
IPC2bits.U1RXIP = 4; //interrupt priority level for receive
IPC3bits.U1TXIP = 4; //interrupt ptiority level for transmit
U1STA = 0;
 
U1MODE = 0; //8-bit data, no parity, 1 stop bit
U1MODEbits.UARTEN = 1; //enable the module

U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 1; //interrupt generated transmit is complete
IFS0bits.U1RXIF = 0; //clear receive interrupt flag
 
U1STAbits.UTXEN = 1; //enable transmission
IEC0bits.U1RXIE = 1; //UART receiver interrupt enabled
IEC0bits.U1TXIE = 0; //UART transmitter interrupt disabled
//END UART SETUP
}
 
int uart1puts(char temp)
{
while(U1STAbits.UTXBF); //transmit only if TX buffer is empty
U1TXREG = temp;
return temp;
}
 
int main (void)
{

OSCCON = 0X70; // set internal oscillator to 8MHz
TRISA= 0; // configure port A as output
TRISB = 1; // configure port B as input
AD1PCFG=0xffff; // configure port B input as digital
 
while(1)
{
reset_detect();// Checks for reset and if found prints Device Detect to LCD
//if (presence_detect == 0){ // If presence_detect = 0, meaning device present
make_output(); // Set pin to output for next writes
write_byte(0xCC); // Skip ROM, we only have one device and read temper
write_byte(0x44); // Convert T
//__delay_ms(750); // For 12 bit res, the max conversion time=750 ms
reset_detect();
write_byte(0xCC); // Skip ROM
write_byte(0xBE);// Read Scratchpad Command
 
unsigned char byte1= read_byte();// Returns 1st byte of Result
unsigned char byte2= read_byte();// Returns 2nd byte of Result

unsigned int bytes1and2= (byte2<<8 | byte1) ; // combine bytes by shifting byte
double cvalue = bytes1and2 / 16.0;
//double fvalue = 1.8*cvalue + 32.0;
uart_init();
uart1puts( 'Temp',cvalue); // sensed temperature has stored in cvalue is this correct way to display?

if (cvalue>=20)//if temperature is higher than 20
{
HEATER = ON;
//__delay_ms(100);
}
else{
HEATER = OFF;
//__delay_ms(100);
}
}
}
 

Please have check my code and help me.
Thank you
post edited by Gouthami c v - 2019/08/12 23:31:42
#1
ric
Super Member
  • Total Posts : 23598
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART PROBLEM 2019/08/12 23:46:14 (permalink)
0
There's a few things wrong with this line
uart1puts( 'Temp',cvalue); // sensed temperature has stored in cvalue is this correct way to display?

First, I would assume uart1puts() to be similar to the standard function puts(), in that it simply outputs a fixed string.
There are no formatting functions like in printf().
Second, you have put single quotes around the string. C requires double quotes around strings, single quotes are used for single characters.
 
So, first you need to convert your number to a fixed string, then you can output that string.
Try this:
char buffer[16];    //array to hold the string
sprintf(buffer,"Temp %d",cvalue);    // create a string containing the value converted to decimal
uart1puts(buffer);    // output the string we created

You may need to #include <stdio.h> to be able to use sprintf()
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#2
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/13 00:29:08 (permalink)
0
Thank you for replying i have changed as per you told, but code is not getting build its showing warnings.Should i change any thing in int uartputs(char c), i am getting warning here.

int uartputs(char c)
{
while(U1STAbits.UTXBF); //transmit only if TX buffer is empty
U1TXREG = c;
return c;
}

I am getting these three warnings.
newmain.c:236:6: warning: format '%d' expects type 'int', but argument 3 has type 'double'
newmain.c:237:6: warning: passing argument 1 of 'uartputs' makes integer from pointer without a cast
newmain.c:74:5: note: expected 'char' but argument is of type 'char *'


 
Thank you.
 
#3
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/13 01:33:48 (permalink)
0
Hi i have used below statement for double cvalue 

sprintf(buffer,"Temp %lf bytes.\n",cvalue);     // create a string containing the value converted to decimal

but still code is not building.Could you please help me.
 
Thank you.
 
#4
ric
Super Member
  • Total Posts : 23598
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART PROBLEM 2019/08/13 01:48:46 (permalink)
0
Ahh, I didn't notice that uart_puts() was in the code in your first post.
Why did you use a name that appears to print a string for a routine that just prints one character?
 
I would rename that function to uart_putc(), and there's no point returning the character you just printed.
Then I would add a function that uses that function to print a string.
e.g.
//send one character to UART1
void uart1putc(char temp)
{
    while(U1STAbits.UTXBF); //transmit only if TX buffer is empty
     U1TXREG = temp;
}
//send a string to uart1
void uart1puts(char * buf)
{
    while (*buf)    // loop while we haven't hit the terminal NULL
        uart1putc(*buf++);    //send this character, then advance the pointer
}


I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#5
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/13 03:02:46 (permalink)
0
Hi i have changed code still code not building

 
int main (void)
{
 
while(1)
{
 
unsigned int bytes1and2= (byte2<<8 | byte1) ; // combine bytes by shifting byte
double cvalue = bytes1and2 / 16.0;

uart_init();
char buffer[16]; //array to hold the string
sprintf(buffer,"Temp %lf bytes.\n",cvalue); // create a string containing the value converted to decimal
 
uartputs(buffer); // output the string we created
 
}
}

void uart_init(void)
{
// UART_SETUP
U1BRG = 25; //Baud rate set to 9600
IPC2bits.U1RXIP = 4; //interrupt priority level for receive
IPC3bits.U1TXIP = 4; //interrupt ptiority level for transmit
U1STA = 0;
 
U1MODE = 0; //8-bit data, no parity, 1 stop bit
U1MODEbits.UARTEN = 1; //enable the module

U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 1; //interrupt generated transmit is complete
IFS0bits.U1RXIF = 0; //clear receive interrupt flag
 
U1STAbits.UTXEN = 1; //enable transmission
IEC0bits.U1RXIE = 1; //UART receiver interrupt enabled
IEC0bits.U1TXIE = 0; //UART transmitter interrupt disabled
//END UART SETUP
}

//send one character to UART1
void uartputc(char temp)
{
while(U1STAbits.UTXBF); //transmit only if TX buffer is empty
U1TXREG = temp;
}
//send a string to uart1
void uartputs(char * buf)
{
while (*buf) // loop while we haven't hit the terminal NULL
uartputc(*buf++); //send this character, then advance the pointer
}
 

is this below statement correct for double data type?

sprintf(buffer,"Temp %lf bytes.\n",cvalue); // is this correct because when i remove %lf bytes, cvalue code is building

when ever i build code i getting this
nbproject/Makefile-default.mk:135: recipe for target 'dist/default/production/UARTTEMP.X.production.hex' failed
make[2]: Leaving directory 'D:/Projects/New Folder/UARTTEMP.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/Projects/New Folder/UARTTEMP.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
 
Thank you.
post edited by Gouthami c v - 2019/08/13 03:11:00
#6
ric
Super Member
  • Total Posts : 23598
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART PROBLEM 2019/08/13 03:24:38 (permalink)
0
You don't need "%lf", just "%f" is fine for a float.
 

when ever i build code i getting this
nbproject/Makefile-default.mk:135: recipe for target 'dist/default/production/UARTTEMP.X.production.hex' failed
make[2]: Leaving directory 'D:/Projects/New Folder/UARTTEMP.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/Projects/New Folder/UARTTEMP.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

There must be an earlier error that you are not showing.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#7
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/13 03:45:57 (permalink)
0
No still i am geeting same
#8
ric
Super Member
  • Total Posts : 23598
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART PROBLEM 2019/08/13 03:58:15 (permalink)
5 (1)
Gouthami c v
No still i am geeting same

Can't help if you don't show the FULL compile log. Crystal ball is playing up.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#9
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/13 04:17:08 (permalink)
0

 
/*
* File: newmain.c
* Author: gouthami
*
* Created on August 7, 2019, 12:02 PM
*/
 
 
// PIC24F04KA200 Configuration Bit Settings
 
// 'C' source line config statements
 
// FBS
 
 
 
// FGS
#pragma config GWRP = OFF // General Segment Code Flash Write Protection bit (General segment may be written)
#pragma config GCP = OFF // General Segment Code Flash Code Protection bit (No protection)
 
 
 
// FOSCSEL
#pragma config FNOSC = FRCPLL // Oscillator Select (Fast RC oscillator with divide-by-N with PLL module (FRCDIV+PLL))
#pragma config IESO = OFF // Internal External Switch Over bit (Internal External Switchover mode disabled (Two-Speed Start-up disabled))
 
 
 
// FOSC
#pragma config POSCMOD = NONE // Primary Oscillator Configuration bits (Primary oscillator disabled)
#pragma config OSCIOFNC = OFF // CLKO Enable Configuration bit (CLKO output signal active on the OSCO pin; primary oscillator must be disabled or configured for the External Clock mode (EC) for the CLKO to be active (POSCMD<1:0>))
#pragma config POSCFREQ = HS // Primary Oscillator Frequency Range Configuration bits (Primary oscillator/external clock input frequency greater than 8 MHz)
#pragma config SOSCSEL = SOSCHP // SOSC Power Selection Configuration bits (Secondary oscillator configured for high-power operation)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock switching is disabled, Fail-Safe Clock Monitor is disabled)
 
 
 
// FWDT
#pragma config WDTPS = PS32768 // Watchdog Timer Postscale Select bits (1:32,768)
#pragma config FWPSA = PR128 // WDT Prescaler (WDT prescaler ratio of 1:128)
#pragma config WINDIS = OFF // Windowed Watchdog Timer Disable bit (Standard WDT selected; windowed WDT disabled)
#pragma config FWDTEN = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
 
 
 
// FPOR
#pragma config BOREN = BOR3 // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware; SBOREN bit disabled)
#pragma config PWRTEN = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config BORV = LPBOR // Brown-out Reset Voltage bits (Low-Power Brown-out reset occurs around 2.0V)
#pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RA5 input pin disabled)
 
 
 
// FICD
#pragma config ICS = PGx2 // Reserved (PGC2/PGD2 are used for programming the device)
 
 
 
// FDS
#pragma config DSWDTPS = DSWDTPSF // Deep Sleep Watchdog Timer Postscale Select bits (1:2,147,483,648 (25.7 Days))
#pragma config DSLPBOR = ON // Deep Sleep Zero-Power BOR Enable bit (Deep Sleep BOR enabled in Deep Sleep)
#pragma config DSWDTEN = OFF // Deep Sleep Watchdog Timer Enable bit (DSWDT disabled)
 
 
 
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
 
 
 
#include <xc.h>
#include <stdio.h>
#define FCY 4000000
#define BAUDRATE 9600
#define BRGVAL ((FCY/BAUDRATE)/16)-1
#include <libpic30.h> //for delay routines#
#include "system.h"
 
 
 
int main (void)
{

OSCCON = 0X70; // set internal oscillator to 8MHz
TRISA= 0; // configure port A as output
TRISB = 1; // configure port B as input
AD1PCFG=0xffff; // configure port B input as digital
 
 
 
while(1)
{
 
double cvalue = bytes1and2 / 16.0;

uart_init();
char buffer[16]; //array to hold the string
uartputs(buffer); // output the string we created
sprintf(buffer,"Temp %f",cvalue); // create a string containing the value converted to decimal
}
}
 
void uart_init(void)
{
// UART_SETUP
U1BRG = 25; //Baud rate set to 9600
IPC2bits.U1RXIP = 4; //interrupt priority level for receive
IPC3bits.U1TXIP = 4; //interrupt ptiority level for transmit
U1STA = 0;
 
U1MODE = 0; //8-bit data, no parity, 1 stop bit
U1MODEbits.UARTEN = 1; //enable the module

U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 1; //interrupt generated transmit is complete
IFS0bits.U1RXIF = 0; //clear receive interrupt flag
 
U1STAbits.UTXEN = 1; //enable transmission
IEC0bits.U1RXIE = 1; //UART receiver interrupt enabled
IEC0bits.U1TXIE = 0; //UART transmitter interrupt disabled
//END UART SETUP
}

//send one character to UART1
void uartputc(char temp)
{
while(U1STAbits.UTXBF); //transmit only if TX buffer is empty
U1TXREG = temp;
}
//send a string to uart1
void uartputs(char * buf)
{
while (*buf) // loop while we haven't hit the terminal NULL
uartputc(*buf++); //send this character, then advance the pointer
}
 
 
 
 
 
 

This is the code i am using
I am getting error like this when i build the code.

 
 
 

CLEAN SUCCESSFUL (total time: 202ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Projects/New Folder/UARTTSE.X'
make -f nbproject/Makefile-default.mk dist/default/production/UARTTSE.X.production.hex
make[2]: Entering directory 'D:/Projects/New Folder/UARTTSE.X'
"C:\Program Files (x86)\Microchip\xc16\v1.36\bin\xc16-gcc.exe" main.c -o build/default/production/main.o -c -mcpu=24F04KA200 -MMD -MF "build/default/production/main.o.d" -g -omf=elf -DXPRJ_default=default -legacy-libc -O0 -msmart-io=1 -Wall -msfr-warn=off
"C:\Program Files (x86)\Microchip\xc16\v1.36\bin\xc16-gcc.exe" -o dist/default/production/UARTTSE.X.production.elf build/default/production/main.o -mcpu=24F04KA200 -omf=elf -DXPRJ_default=default -legacy-libc -Wl,,,--defsym=__MPLAB_BUILD=1,,--script=p24F04KA200.gld,--stack=16,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map="dist/default/production/UARTTSE.X.production.map",--report-mem,--memorysummary,dist/default/production/memoryfile.xml
c:\program files (x86)\microchip\xc16\v1.36\bin\bin\..\bin/elf-ld.exe: Link Error: region program is full (dist/default/production/UARTTSE.X.production.elf section .text)
build/default/production/main.o: Link Error: Could not allocate section .const, size = 8 PC units, attributes = psv page
floatundidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatdidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dtype.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpropagateNaN.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
adddf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
mulsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
udivsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
subdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
muldf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatsidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fixdfsi.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
extendsfdf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
deqltle.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xdnorm.XX_elo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldunsca.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
ldiv.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
div.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xgenld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldtob_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputfld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xvacopy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputtxt.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
strchr.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
memcpy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
sprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatundisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
futil.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatunsisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
delay32.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt_start_mode_normal.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
data_init_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt0_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
build/default/production/main.o: Link Error: Could not allocate section .text, size = 512 PC units, attributes = code
data_init: Link Error: Could not allocate section .dinit, size = 100 PC units, attributes = code keep
delay32.Leo: Link Error: Could not allocate section .init.delay32, size = 28 PC units, attributes = code
build/default/production/main.o: Link Error: Could not allocate section .const, size = 8 PC units, attributes = psv page
floatundidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatdidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dtype.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpropagateNaN.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
adddf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
mulsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
udivsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
subdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
muldf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatsidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fixdfsi.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
extendsfdf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
deqltle.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xdnorm.XX_elo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldunsca.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
ldiv.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
div.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xgenld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldtob_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputfld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xvacopy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputtxt.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
strchr.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
memcpy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
sprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatundisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
futil.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatunsisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
delay32.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt_start_mode_normal.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
data_init_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt0_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
data_init: Link Error: Could not allocate section .dinit, size = 100 PC units, attributes = code keep
delay32.Leo: Link Error: Could not allocate section .init.delay32, size = 28 PC units, attributes = code
build/default/production/main.o: Link Error: Could not allocate section .const, size = 8 PC units, attributes = psv page
floatundidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatdidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dtype.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpropagateNaN.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
adddf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
mulsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
udivsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
subdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
muldf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatsidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fixdfsi.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
extendsfdf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
deqltle.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xdnorm.XX_elo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldunsca.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
ldiv.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
div.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xgenld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldtob_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputfld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xvacopy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputtxt.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
strchr.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
memcpy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
sprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatundisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
futil.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatunsisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
delay32.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt_start_mode_normal.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
data_init_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt0_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
delay32.Leo: Link Error: Could not allocate section .init.delay32, size = 28 PC units, attributes = code
build/default/production/main.o: Link Error: Could not allocate section .const, size = 8 PC units, attributes = psv page
floatundidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatdidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dtype.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpropagateNaN.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
adddf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
mulsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
udivsi3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
subdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
muldf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatsidf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fixdfsi.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
extendsfdf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dunpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsi3.eo: Link Error: Could not allocate sectinbproject/Makefile-default.mk:135: recipe for target 'dist/default/production/UARTTSE.X.production.hex' failed
make[2]: Leaving directory 'D:/Projects/New Folder/UARTTSE.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/Projects/New Folder/UARTTSE.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
on .text, size = 0 PC units, attributes = code
divdf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
dgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
deqltle.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xdnorm.XX_elo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldunsca.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
ldiv.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
div.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xgenld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xldtob_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputfld_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xvacopy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xputtxt.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
strchr.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
memcpy.XX_eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
xprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
sprintf_fF.XXeo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatundisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fcompare.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
futil.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
funpack2.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fpack.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
floatunsisf.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
fgtge.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
divsf3.eo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
delay32.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt_start_mode_normal.Leo: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
data_init_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
crt0_standard.o: Link Error: Could not allocate section .text, size = 0 PC units, attributes = code
Link Error: Could not allocate program memory
make[2]: *** [dist/default/production/UARTTSE.X.production.hex] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
 
 
 
BUILD FAILED (exit value 2, total time: 2s)
 
 
 

please help me for this 
Thank you.
post edited by Gouthami c v - 2019/08/13 04:22:41
#10
Nikolay_Po
Super Member
  • Total Posts : 1888
  • Reward points : 0
  • Joined: 2012/04/01 13:49:27
  • Location: Russia, Novorossiysk
  • Status: online
Re: UART PROBLEM 2019/08/13 11:01:03 (permalink)
0
PIC24F04 has too few of program memory to deal with standard sprintf(). You have to use something more compact than sprintf() and floating point numbers.
I think you have to calculate all in integers, avoiding floats (doubles) completely. Then try with sprintf(). May be it will fit, may be not. If with integers there is still not enough place for sprintf(), use your own function to convert the integer number to characters or try to use itoa() function which should be more compact than printf().
#11
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/13 23:14:59 (permalink)
0
Thank you replying, i have tried with your statement still i am getting same.

itoa(cvalue,buffer,10); // here 10 means decimal
printf("Temp is %s\n",buffer); // create a string containing the value converted to decimal

while compiling i am getting this warning

newmain.c:91:6: warning: implicit declaration of function 'itoa'

please help me
 
Thank you.
#12
ric
Super Member
  • Total Posts : 23598
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART PROBLEM 2019/08/13 23:32:35 (permalink)
0
Unfortunately, the stdlib supplied with XC16 does not contain an itoa() function.
What if you just use %d in the printf() function?
Integer output takes much less code than floating point.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#13
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/14 02:33:24 (permalink)
0
Hi,
if i use printf with out below statement i am getting errors code wouldn't build.

itoa(cvalue,buffer,10); // here 10 means decimal



Thank you.
 
post edited by Gouthami c v - 2019/08/14 02:35:45
#14
Gouthami c v
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2019/07/11 01:55:44
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/14 03:04:30 (permalink)
0
Just to check Uart function i have tried same code to display string"Temp" that is also not happening,code is getting build but string not displayed, i have checked in debug, buffer is getting load with string value but its not displaying, what may be the issue could you please let me know.
here is my code

 
 
 
int main (void)
{
 
 
 
whie(1)
 
 
 
{
 
 
 
char buffer[16]; //array to hold the string
uart_init();
sprintf(buffer,"Temp"); // create a string containing the value converted to decimal

uartputs(buffer);// output the string we created
 
 
 
}
 
 
 
}
 
 
 
void uart_init(void)
{
// UART_SETUP
U1BRG = 25; //Baud rate set to 9600
IPC2bits.U1RXIP = 4; //interrupt priority level for receive
IPC3bits.U1TXIP = 4; //interrupt ptiority level for transmit
U1STA = 0;
 
 
 
U1MODE = 0; //8-bit data, no parity, 1 stop bit
U1MODEbits.UARTEN = 1; //enable the module

U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 1; //interrupt generated transmit is complete
IFS0bits.U1RXIF = 0; //clear receive interrupt flag
 
 
 
U1STAbits.UTXEN = 1; //enable transmission
IEC0bits.U1RXIE = 1; //UART receiver interrupt enabled
IEC0bits.U1TXIE = 0; //UART transmitter interrupt disabled
//END UART SETUP
}
 
 
 

//send one character to UART1
void uartputc(char temp)
{
while(U1STAbits.UTXBF); //transmit only if TX buffer is empty
U1TXREG = temp;
}
//send a string to uart1
void uartputs(char *buf)
{
while (*buf) // loop while we haven't hit the terminal NULL
uartputc(*buf++); //send this character, then advance the pointer
}
 
 
 

is this code correct to display string?help me
Thank you.
post edited by Gouthami c v - 2019/08/14 03:09:54
#15
rodims
Super Member
  • Total Posts : 1515
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: online
Re: UART PROBLEM 2019/08/14 05:48:20 (permalink)
5 (1)
For sure this is not the code which you are using. So this does not encourage to review your code, if it does not even compile.
Also, please remove your uart_init initialisation code from the while loop. This does not make sense.
Using sprintf to make a string out of a string is a waste of program memory, but may be that's ok for testing. 
Since you removed the RX interrupt function, you MUST NOT enable rx interrupts
IEC0bits.U1RXIE = 1; //UART receiver interrupt enabled
Can you check your UART1TX pin with a scope or logic analyzer ? 
#16
LdB_ECM
Senior Member
  • Total Posts : 144
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/14 07:38:44 (permalink)
0
Come on be serious there is an obvious problem in the while (1) loop lets shorten it up
So stop and take a minute to really think about this code ... let me even mark a line as stupid
while(1) {
   char buffer[16]; //array to hold the string
   uart_init(); /* STUPID */
   sprintf(buffer,"Temp"); // create a string containing the value converted to decimal
   uartputs(buffer);// output the string we created
}

What do you think the stupid line does each loop?
So you load up the TX buffer and promptly do what on the next loop thru stupid?
post edited by LdB_ECM - 2019/08/14 07:40:56
#17
Jim Nickerson
User 452
  • Total Posts : 6187
  • Reward points : 0
  • Joined: 2003/11/07 12:35:10
  • Location: San Diego, CA
  • Status: offline
Re: UART PROBLEM 2019/08/14 07:53:19 (permalink)
0
LdB_ECM
Come on be serious there is an obvious problem in the while (1) loop lets shorten it up
So stop and take a minute to really think about this code ... let me even mark a line as stupid
while(1) {
   char buffer[16]; //array to hold the string
   uart_init(); /* STUPID */
   sprintf(buffer,"Temp"); // create a string containing the value converted to decimal
   uartputs(buffer);// output the string we created
}

What do you think the stupid line does each loop?
So you load up the TX buffer and promptly do what on the next loop thru stupid?


As a student he is trying to learn, at least he wrote something.
#18
rodims
Super Member
  • Total Posts : 1515
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: online
Re: UART PROBLEM 2019/08/14 09:22:36 (permalink) ☄ Helpfulby Gouthami c v 2019/08/16 04:34:53
0
Learning usually starts with listening.
 
I'm not sure whether your questions intend to teach me ? 
 
I did not recommend you to skip your initialization, but to remove it from the loop (move it out of your while loop).  If that is not clear enough: move it outside = above your while loop.
 
I cannot see whether you got the points of my previous post or not, you seem to have your own opinion.
 
 
 
post edited by rodims - 2019/08/14 10:46:45
#19
nigelwright7557
Super Member
  • Total Posts : 284
  • Reward points : 0
  • Joined: 2006/11/06 08:15:51
  • Location: 0
  • Status: offline
Re: UART PROBLEM 2019/08/14 09:39:35 (permalink)
0
As a hardware engineer as well as a software engineer the first thing I would do is send 0xaa to the port constantly and see if the UART is outputting that and also at the right speed 104uS per bit.
 
 
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5