View previous topic :: View next topic |
Author |
Message |
darrepac
Joined: 19 Jan 2005 Posts: 22
|
Printf(), putc() behaviour regarding hanging processor |
Posted: Wed Feb 16, 2005 8:23 am |
|
|
Hi All,
I have a question since a long time... Does the PIC need to wait the transfert over RS232 during a printf(0 or putc() function? or is there somewhere a buffer to prevent that?
With examples:
printf ("Hello world");
instruction2;
for coming from printf to instruction to I have to wait the complete transmission of the data over RS232 (time will depend on baudrate) or only few cycles to setup the things and transfer data to internal buffer?
Same for putc()... Do I need to wait the complete transmission of the character or not?
Thanks
Pascal |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Feb 16, 2005 8:28 am |
|
|
It waits. You can use sprintf to a buffer and do the transmission yourself. That is how I would do it. |
|
|
darrepac
Joined: 19 Jan 2005 Posts: 22
|
|
Posted: Wed Feb 16, 2005 8:29 am |
|
|
It was also my asumption and that's why I have done like this too...but I wanted to check, to be sure I am doing work for nothing |
|
|
darrepac
Joined: 19 Jan 2005 Posts: 22
|
|
Posted: Wed Feb 16, 2005 10:23 am |
|
|
Just agin to be sure, interruption are still working during a printf()? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Feb 16, 2005 11:54 am |
|
|
You will have to look at the lst file for that. That's why I hate all that "automagic" code that CCS produces. You can't tell what is going on without diving into it and they can change it at a whim. |
|
|
darrepac
Joined: 19 Jan 2005 Posts: 22
|
|
Posted: Thu Feb 17, 2005 7:26 am |
|
|
shame :-( |
|
|
darrepac
Joined: 19 Jan 2005 Posts: 22
|
|
Posted: Thu Feb 17, 2005 2:15 pm |
|
|
I have the impression that Interrupt are disabled during putc()...but I am not sure at all , does someone could confirm?
thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 17, 2005 2:25 pm |
|
|
Whenever you compile, a listing file (.LST) is generated, which you
can examine to see what the compiler is doing. In the case of
putc(), here is the listing for a 16F877 with the hardware USART.
You then look in the data sheet in the Special Function Registers
table, to see what registers and bits are being used. You also
have to take into account the bank selection, but in the case
below, it's all in Bank 0.
Code: | 0000 00307 ....................
0000 00308 .................... putc(0x55);
0014 3055 00309 MOVLW 55
0015 1E0C 00310 BTFSS 0C.4
0016 2815 00311 GOTO 015
0017 0099 00312 MOVWF 19
0000 00313 .................... |
|
|
|
darrepac
Joined: 19 Jan 2005 Posts: 22
|
|
Posted: Thu Feb 17, 2005 2:39 pm |
|
|
Ok thanks in fact I have done a mistake in my reading causing me troubles to understand...now it is far clearer |
|
|
|