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 support@ccsinfo.com

dsPIC33F UART, strange behaviour, timing problem?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sth_tob



Joined: 19 Aug 2014
Posts: 2

View user's profile Send private message

dsPIC33F UART, strange behaviour, timing problem?
PostPosted: Tue Aug 19, 2014 6:31 pm     Reply with quote

Hello there!

Someone could explain me, why the behaviour of the following code is, that the LED toggles every 1 second, but the printf(char *) function doesn't send my desired string to the UART1 in same time intervall?

First i thought there's some timing problem, because the 7.37MHz are maybe not OK for the 9600 Baudrate. But that's not the reason i guess, because my UART receiver (RS232 serial port) receives only correct strings!

Here's a test code that demonstrates the behaviour. Does sequential code execution happens here? Or does the compiler automatically decides to "skip" printf(char *) statements? I can't imagine that the "send string functions" isn't fast enough to execute within that 1000ms loop. If i remove the delay_ms(1000), my RS232 console gets an excessive amount of strings, more than a whole console window within a second!!

Code:

#include <33FJ128GP802.h>

#FUSES NOWDT, CKSFSM, NOJTAG

#use delay(internal=7370000)

#pin_select U1TX=PIN_B4
#pin_select U1RX=PIN_B3
#use rs232(UART1, baud=9600)

int main() {
   while(1) {
      output_toggle(PIN_B15);
      printf("This is a Teststring!");
      delay_ms(1000);
   }
   return 0;
}


Also, 1s periodical execution in a Timer ISR also doesn't send in 1s intervalls. I hope you could help me to use the UART right!

Thank you!
sth_tob



Joined: 19 Aug 2014
Posts: 2

View user's profile Send private message

PostPosted: Tue Aug 19, 2014 7:03 pm     Reply with quote

I'm using a MAX3232 level converter. I think it's damaged Shocked . It has 2 channels and 1 channel doesn't work, while the other have this "just sometimes send" behaviour. Also, it doesn't even work with recommended 100nf capacitors, i had to use at least 1µF to get some RS232 output. Crying or Very sad Rolling Eyes
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Wed Aug 20, 2014 8:52 am     Reply with quote

Have you got all five capacitors. They are all required (including the one on the incoming 3.3v rail). The test circuits all show this, but they then refer only to the ones forming the actual charge pump (4 capacitors). Unless the source impedance of the supply is very low, the fifth capacitor on the incoming rail is just as important....
Check the voltages on pin2, and pin6. You should have about +/- 5.5v here.
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