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

Help with rs-232 for PIC16F18323 [SOLVED]

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



Joined: 21 Mar 2018
Posts: 51

View user's profile Send private message

Help with rs-232 for PIC16F18323 [SOLVED]
PostPosted: Fri Oct 13, 2023 2:51 pm     Reply with quote

Compiler is 5.116, programmer is ICD-U64. I was expecting the first message, then the second message each second thereafter:

Code:

#include <16F18323.h>
#fuses PUT, NOWDT
#use delay(internal=32MHZ)
#pin_select U1TX=PIN_C4
#use rs232(UART1,baud=28800,parity=N,bits=8,errors,stream=VT)
void main(void)
{
 fprintf(VT, "Hello World!!\r\n");
 while(TRUE)
 {
  fprintf(VT, "Hello World??\r\n");
  delay_ms(1000);
 }
}


The above code produces this output using CoolTerm:

Code:

Hello World!!
Hello World?ΓΏ


The program seems to choke on the last question mark. Same behavior whether U1RX is specified or not or if the delay_ms function is present or not. Any ideas?


Last edited by randy.shaffer on Mon Jun 10, 2024 10:32 am; edited 1 time in total
temtronic



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

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 8:37 pm     Reply with quote

so have you just used a loopback wire on the PC serial link and confirmed it's not a 'coolterm' or other PC problem ??

also what is the actual hardware connecting PIC to PC ? I have to assume it's not PIC -->1488 to PC Comport pin 3......
randy.shaffer



Joined: 21 Mar 2018
Posts: 51

View user's profile Send private message

PostPosted: Mon Oct 16, 2023 2:24 pm     Reply with quote

If I re-compile with ICD = TRUE, the program works in the debugger. But it doesn't work outside of the debugger. Do I need a #device ICD = something? to make it work on its own?
temtronic



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

View user's profile Send private message

PostPosted: Mon Oct 16, 2023 2:50 pm     Reply with quote

Hopefully someone that uses that ICD-U64 will respond BUT my gut say that 'ICD= FALSE' is needed in your code
PLUS
in the IDE, set the 'build configuration' to 'release' NOT 'debug'.

Something.. IDE, programmer, man in the moon, is not configuring for 'release', instead going to 'debug' .

Again, i don't use the ICD-U64 but got 'stung' when MPLAB 8.xx defaulted to 'debug'. I called them, they changed their code, MY default is 'release'. The IT guy couldn't understand that I never use 'debug'.....3 hours later he finally understood......

Jay
randy.shaffer



Joined: 21 Mar 2018
Posts: 51

View user's profile Send private message

PostPosted: Mon Oct 16, 2023 3:34 pm     Reply with quote

Jay, thank you for the insight. It now gets more weird. I tried ICD = FALSE, but the compiler didn't like it. Then I tried various ICD = something and got no change. Then I tried
Code:

#device ICD=

And it worked! What's more bizarre is that statement seems to have flipped a switch as now I am able to compile without the device statement and everything is working as expected. So, ICD = nothing apparently made the IDE, programmer, or the man in the moon happy. If anyone out there can shed some light on how/why this worked, I would greatly appreciate it! Jay, thanks again for the inspiration.
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Mon Oct 16, 2023 4:15 pm     Reply with quote

If you're using the IDE, View -> C/ASM list. If not, there should be a .lst file in the directory.

At the bottom is the fuses; it will look something like this:

Code:
Configuration Fuses:
   Word  1: FF8C   NOEXTOSC RSTOSC_HFINTRC_64MHZ NOCLKOUT CKS FCMEN
   Word  2: F73D   MCLR PUT NOLPBOR NOBROWNOUT BORV19 ZCDDIS NOPPS1WAY STVREN NODEBUG NOXINST
   Word  3: FF9F   WDTSW NOWDT WDTWIN_SW WDTCLK_SW
   Word  4: DFFF   NOWRT NOWRTC NOWRTB NOWRTD SCANE NOLVP
   Word  5: FFFE   PROTECT NOCPD
   Word  6: FFFF   NOEBTR NOEBTRB


Compile & look at the .lst file with & without the ICD=TRUE along with the weird one you found which works. Sounds like a compiler bug which seems to perhaps be messing with the fuses?
randy.shaffer



Joined: 21 Mar 2018
Posts: 51

View user's profile Send private message

PostPosted: Wed Oct 18, 2023 9:43 am     Reply with quote

Thank you, newguy, I tried compiling with ICD=TRUE and ICD= and found no difference in the fuses. Does anyone know if there is an ICD=something that corresponds to released code? The compiler doesn't like ICD=FALSE or ICD=0. By the way, should the statement #device ICD = (whatever) come before or after the #fuses directive?
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Wed Oct 18, 2023 9:44 am     Reply with quote

With CCS, whatever comes last in the file overrides what came before when it comes to fuses. Same applies to the clock (#use delay) directive.
randy.shaffer



Joined: 21 Mar 2018
Posts: 51

View user's profile Send private message

VDD not connected
PostPosted: Mon Jun 10, 2024 10:34 am     Reply with quote

I didn't have VDD connected because I wasn't using the VDD from the ICD-64. However, it appears that VDD must be connected for everything to work properly, even when the MCU is powered by a source external to the programmer.
Ttelmah



Joined: 11 Mar 2010
Posts: 19488

View user's profile Send private message

PostPosted: Mon Jun 10, 2024 11:34 am     Reply with quote

The programmer unit, when setup with 'target supplies power', uses
the supply connection to test that the chip has a legal supply, and will
not allow you to program, unless it is seen as OK. Hence your problwm.
A lot of the units will give you an error message to say that the supply
is not OK, but this depends on the ICD, and the firmware involved.
randy.shaffer



Joined: 21 Mar 2018
Posts: 51

View user's profile Send private message

PostPosted: Mon Jun 10, 2024 11:37 am     Reply with quote

Thank you for the clarification, much obliged.
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