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

Migration from 16F15223 to 16F18323

 
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: 48

View user's profile Send private message

Migration from 16F15223 to 16F18323
PostPosted: Thu Oct 12, 2023 1:11 pm     Reply with quote

Code:
//!#include <16F15223.h> // device file
#include <16F18323.h> // device file
#use delay(internal = 32MHZ)
#fuses PUT, NOWDT // 16F18323
//!#fuses PUT_16MS, NOWDT // 16F15223
#use rs232(baud=28800,parity=N,xmit=PIN_C4,bits=8,stream=VT)
#define TEN_MS 0xD8EF // 65535 - 10000 = 55535, 1 MHz/10000 = 100 Hz
void timer1_ISR(void); // prototype
unsigned int16 FREE_RUNNING_TIMER = 0;
void main(void)
{
 setup_timer_1(T1_INTERNAL | T1_DIV_BY_8); // clocked @ Fosc/(4*8) = 1 MHz
 enable_interrupts(INT_TIMER1); // enable timer interrupts
 enable_interrupts(global); // enable all interrupts
 set_timer1(TEN_MS); // initialize timer for 10 ms interrupts
 disable_interrupts(GLOBAL);
 fprintf(VT, "Hello World!!\r\n");
 enable_interrupts(GLOBAL);
 while(TRUE)
 {
  if(FREE_RUNNING_TIMER > 100)
  {
   disable_interrupts(GLOBAL);
   fprintf(VT, "Hello World??\r\n");
   enable_interrupts(GLOBAL);
   FREE_RUNNING_TIMER = 0;
  }
 }
}
#INT_TIMER1
void timer1_ISR(void)
{
 clear_interrupt(INT_TIMER1);
 FREE_RUNNING_TIMER++;
 set_timer1(TEN_MS);
}


Compiler is 5.116. The code above works with the 15223 with one Hello World!! and repeated Hello World?? once each second thereafter. On the 18323, I only get the first Hello World!! after programming and no Hello World??. If I start up w/o programming, I get nothing from the VT stream.
temtronic



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

View user's profile Send private message

PostPosted: Thu Oct 12, 2023 2:29 pm     Reply with quote

hmmmm.does that PIC have PPS pins ?? Ones where YOU can program what pin is used for which peripheral ????
randy.shaffer



Joined: 21 Mar 2018
Posts: 48

View user's profile Send private message

PostPosted: Thu Oct 12, 2023 2:30 pm     Reply with quote

Yes, sir. I tried:

#pin_select TX1 = PIN_C4

but no change.
temtronic



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

View user's profile Send private message

PostPosted: Thu Oct 12, 2023 2:45 pm     Reply with quote

hmm, after #fuses and before #use rs232(....) ? Order is kinda important....

also wondering if you have to 'PPS' BOTH TX and RX pins to make compiler 'happy' ?

I don't use these new fangled PICs just thinking of weird stuff that can trip you up...
randy.shaffer



Joined: 21 Mar 2018
Posts: 48

View user's profile Send private message

PostPosted: Thu Oct 12, 2023 2:52 pm     Reply with quote

Yes, after fuses and before rs232. I just tried

Code:
#pin_select TX1=PIN_C4
#pin_select RX1=PIN_C5
#use rs232(baud=28800,parity=N,xmit=PIN_C4,bits=8,stream=VT)


and got nothing out of VT. Any idea why I only get something after programming but nothing if I start up with an external supply? The voltage at the chip measures good.
Ttelmah



Joined: 11 Mar 2010
Posts: 19226

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 6:01 am     Reply with quote

Look at the top of the forum at the sticky about how to use PPS.

You are not using the hardware port. You are setting up a software serial.
Use the UART1 syntax shown in the sticky.

On the wake up, look at the rise time of your supply. How is the MCLR
pin wired?. The programmer takes control of this pin.
randy.shaffer



Joined: 21 Mar 2018
Posts: 48

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 9:55 am     Reply with quote

Thank you for the advice. I've removed the timer interrupt to simplify the code. Here is the latest:
Code:

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


It appears now to display part of the second message and then hangs at the delay function:

Code:

Hello World!!
Hello World?ΓΏ


The MCLR pin is connected to the junction of a 10k resistor and 0.1uF capacitor. The resistor is connected to +5V and the capacitor to ground.
gaugeguy



Joined: 05 Apr 2011
Posts: 288

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 10:02 am     Reply with quote

You are not following the advice you have been given.
randy.shaffer



Joined: 21 Mar 2018
Posts: 48

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 11:00 am     Reply with quote

I tried specifying the RX pin as well but still get the same behavior.

Code:

#include <16F18323.h>
#fuses PUT, NOWDT
#use delay(internal=32MHZ)
#pin_select U1TX=PIN_C4
#pin_select U1RX=PIN_C5
#use rs232(UART1,baud=28800,parity=N,bits=8,errors,stream=VT)
randy.shaffer



Joined: 21 Mar 2018
Posts: 48

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 12:43 pm     Reply with quote

gaugeguy, forgive me, but can you be more specific?
gaugeguy



Joined: 05 Apr 2011
Posts: 288

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 2:09 pm     Reply with quote

If you have removed your interrupt routines, why are you enabling interrupts?
randy.shaffer



Joined: 21 Mar 2018
Posts: 48

View user's profile Send private message

PostPosted: Fri Oct 13, 2023 2:13 pm     Reply with quote

I disable the interrupts before sending data to the VT stream and then re-enable after sending. In the past, that has helped with cleaning up a garbled transmission. I hope to add the timer back in after the rs-232 is working.
randy.shaffer



Joined: 21 Mar 2018
Posts: 48

View user's profile Send private message

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

I used the statement:
Code:

#device ICD=

in another program and now this program works as originally posted. Does anyone know why? I'm using the ICD-U64 programmer.
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