CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24F Restart on float print

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
[email protected]



Joined: 07 May 2017
Posts: 2

View user's profile Send private message

PIC24F Restart on float print
PostPosted: Sun May 07, 2017 12:42 pm     Reply with quote

I am using compiler version 5.025. I am having an issue that when I print a float value on uart and the interrupt is on, the controller restarts. I have no idea why is this happening. Can anyone help me? I am using fprintf for printing on uart.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun May 07, 2017 12:52 pm     Reply with quote

We are not mind readers, please post your code.
_________________
Google and Forum Search are some of your best tools!!!!
[email protected]



Joined: 07 May 2017
Posts: 2

View user's profile Send private message

PostPosted: Sun May 07, 2017 12:59 pm     Reply with quote

Code:

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOOSCIO
#FUSES SOSC_DIG

#pin_select U2TX=PIN_D0
#pin_select U2RX=PIN_D11
#use rs232(UART2, baud=9600, errors, BITS =8, stream=UART_GPS)



   enable_interrupts(INT_TIMER1);
   enable_interrupts(INTR_CN_PIN | BUTTON);
   enable_interrupts(INTR_GLOBAL);
   enable_interrupts(INT_RDA2);

   float64 test_f = 3334.2313457;
   
 
  while(1)
  {
      delay_ms(500);
      fprintf(UART_BT," float  OK %5.8f\r", test_f);
  }

Following is the output:

âBoot UART_BT OKf
float 3334.23134569
float 3334.23134569
float 3334.23134569
float 3334.23134569
float 3334.23134569
float 3334.23134569
float Boot UART_BT OKf
float 3334.23134569
float 3334.23134569
float 3334.23134569
float 3334.23134569
float 3334.23134569
float 3334.23134569
float Boot UART_BT OKf
float 3334.23134569
float 3334.23134569

When I comment enable_interrupts it works fine.
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Sun May 07, 2017 1:19 pm     Reply with quote

Increase your stack size.

Float printf, uses a lot of stack.

#BUILD(STACK = 0x200)

If you did some diagnostics, you will almost certainly find that it is a stack overflow triggering the reset.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun May 07, 2017 1:47 pm     Reply with quote

That can't be your real 'test' program, as it has FOUR interrupts enabled and NONE have handlers (code) to deal with them. Also no device header or use clock and the printf format code appears to be wrong (though the compiler fixed it ?)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group