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

16F18325 - UART and I2C pins

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



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

16F18325 - UART and I2C pins
PostPosted: Fri Apr 13, 2018 1:11 am     Reply with quote

Hi all,

I have a existing 16F1825 project board. and would like to change to chip 16F18325.
I have the uart connected to PIN_C4(Tx) and PIN_C5(Rx) and I2C connected pins PIN_C0(SCL) and PIN_C1(SDA).

Below is the code i am trying. The I2C works but uart does not. If anybody can help, thanks. I want to use hardware uart and i2c.

Code:

#include <16F18325.h>
#device ADC=8


#FUSES MCLR
#FUSES PUT
#FUSES NOFCMEN
#FUSES NOCKS
#FUSES BROWNOUT
#FUSES BORV27 
#FUSES NOPROTECT
#FUSES NOCPD
#FUSES NOLVP
#FUSES RSTOSC_HFINTRC
#FUSES NOWDT


#define RTC_SDA PIN_C1 
#define RTC_SCL PIN_C0

#define RS232_RX PIN_C5
#define RS232_TX PIN_C4

#pin_select U1RX=RS232_RX
#pin_select U1TX=RS232_TX

#pin_select SCL2OUT=RTC_SCL
#pin_select SCL2IN=RTC_SCL

#pin_select SDA2OUT=RTC_SDA
#pin_select SDA2IN=RTC_SDA

#use rs232(STREAM=r232,baud=9600, xmit=RS232_TX,rcv=RS232_RX)
#use i2c(master,Fast,sda=RTC_SDA, scl=RTC_SCL, FORCE_HW)

void main()
{

  while(1)
  {   
    printf("Hello');
    delay_ms(3000);
  }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 13, 2018 3:26 am     Reply with quote

What is your CCS compiler version ?
jaikumar



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

PostPosted: Fri Apr 13, 2018 3:38 am     Reply with quote

Compiler version: 5.078
jaikumar



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

PostPosted: Fri Apr 13, 2018 4:02 am     Reply with quote

Thanks PCM programmer.

This post below from Ttelmah helped to make it work.
https://www.ccsinfo.com/forum/viewtopic.php?t=55295&highlight=16f18325
for others who would like to run both uart and i2c see below:
Code:

#fuses MCLR, NOCLKOUT, PUT, BROWNOUT
#fuses LPBOR, BORV27, NOLVP
#fuses NOEXTOSC, RSTOSC_HFINTRC, NOWDT
#fuses NOPPS1WAY


#define RTC_SDA PIN_C1 
#define RTC_SCL PIN_C0

#define RS232_RX PIN_C5
#define RS232_TX PIN_C4

 
#use delay(internal=8M)

#pin_select U1RX=RS232_RX
#pin_select U1TX=RS232_TX

#pin_select SCL1OUT=RTC_SCL 
#pin_select SCL1IN=RTC_SCL

#pin_select SDA1OUT=RTC_SDA 
#pin_select SDA1IN=RTC_SDA
 
#use rs232(UART1,baud=9600, bits=8, stop=1, parity=N )
#use i2c(Master, fast, sda=RTC_SDA, scl=RTC_SCL, force_hw)


Regards,
Jai.
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