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

No RS232 data from PIC16F1827

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



Joined: 09 Sep 2010
Posts: 11
Location: Ely, UK

View user's profile Send private message Visit poster's website

No RS232 data from PIC16F1827
PostPosted: Sat Apr 16, 2011 5:12 am     Reply with quote

Hi,

Having resolved an issue with my micro not running, I have moved on to using RS232 comms. I have written the following test code:

Code:


#include <16F1827.h>
#include <stdio.h>

#fuses INTRC_IO, NOWDT, BROWNOUT, NOMCLR
#use delay(clock = 8000000)
#use rs232(baud=2400, xmit=PIN_B5, rcv=PIN_B2, PARITY=N, BITS=8, STOP=1, STREAM=PC)


void main(void)
{   
   while(1)
   {   
      printf("Testing123");
     output_toggle(PIN_B3);

   }

}


I am not receiving any data at my PC. I have observed PIN_B5 with an oscilloscope, but there is no wave form at all. I can however see that PIN_B3 is toggling so I know the micro is running.

I have used the same set on other PICs and not had any problems.

Could someone guide me as to what the issue is please?

Thanks in advance.

Andrew
_________________
Kind regards

Andrew Ellis
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sat Apr 16, 2011 7:33 am     Reply with quote

I believe if you declare the stream in your use RS232 statement you must use it in your printf statement. Or you can leave it out of both.
I don't have materials to check that out right now.
_________________
The search for better is endless. Instead simply find very good and get the job done.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Apr 16, 2011 7:42 am     Reply with quote

Unfortunately, PCM misses to set the TXCKSEL bit in APFCON1 to select RB5 for TX output.

Code:
#bit TXCKSEL = 0x11e.0
...
TXCKSEL = 1;
AJEFenConsultancy



Joined: 09 Sep 2010
Posts: 11
Location: Ely, UK

View user's profile Send private message Visit poster's website

PostPosted: Sun Apr 17, 2011 2:28 pm     Reply with quote

Hi guys,

thank you for your replies.

I have modified my code so that it now reads:

Code:

#include <16F1827.h>
#include <stdio.h>

#fuses INTRC_IO, NOWDT, BROWNOUT, NOMCLR
#use delay(clock = 8000000)
#use rs232(baud=2400, xmit=PIN_B5, rcv=PIN_B2, PARITY=N, BITS=8, STOP=1, stream=PC)
#bit TXCKSEL = 0x11e.0


void main(void)
{   
   char c = 'H';
   TXCKSEL = 1;

   while(1)
   {   
      fputc(&c, PC);
     output_toggle(PIN_B3);

   }

}


Unfortunately it is still not working. I have lifted pin B5 to ensure the is no load on it, but it is not toggling at all. Do you have any further suggestions please?

Thanks

Andrew
_________________
Kind regards

Andrew Ellis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 17, 2011 3:21 pm     Reply with quote

Download the compiler manual. Look at the fputc() section.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
What does it say the parameter is ? A character or the address of a
character ?
temtronic



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

View user's profile Send private message

PostPosted: Sun Apr 17, 2011 5:15 pm     Reply with quote

or press F11 to get onscreen help !
AJEFenConsultancy



Joined: 09 Sep 2010
Posts: 11
Location: Ely, UK

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 18, 2011 5:06 am     Reply with quote

Thanks for the suggestions.

I realised the mistake I made with fputc(); the code now reads:

Code:

#include <16F1827.h>
#include <stdio.h>

#fuses INTRC_IO, NOWDT, BROWNOUT, NOMCLR
#use delay(clock = 8000000)
#use rs232(baud=2400, xmit=PIN_B5, rcv=PIN_B2, PARITY=N, BITS=8, STOP=1, stream=PC)
#bit TXCKSEL = 0x11e.0


void main(void)
{   
   char c = 'H';
   TXCKSEL = 1;

   while(1)
   {   
      fputc(c, PC);
     output_toggle(PIN_B3);

   }

}


Unfortunately it still is not outputting any data. Do you have any further ideas please?

Andrew
_________________
Kind regards

Andrew Ellis
temtronic



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

View user's profile Send private message

PostPosted: Mon Apr 18, 2011 7:26 am     Reply with quote

What onchip peripherals does that PIC have on the same pin ? Normally you have to disable them when you use pins for a use other than the default use. Check the datasheet AND the CCS header for that PIC.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 18, 2011 12:07 pm     Reply with quote

I assume you're still using vs. 4.108 ? I looked at the .LST file, and I
can't make that version produce code for the hardware UART pins for the
16F1827. I tried various combinations of the main pins and the alternates
for Tx and Rx and I always saw it generate code for a software UART.
I didn't check to see if the software UART code will work or not.

How important is it for you to make this work ?

It is possible to write your own hardware UART routines. Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=26631&start=7
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Apr 19, 2011 1:51 am     Reply with quote

Quote:
I assume you're still using vs. 4.108 ?

That's the bad thing when not telling the CCS version. Apparently, 16F1827 hardware UART is only working since V4.110.
AJEFenConsultancy



Joined: 09 Sep 2010
Posts: 11
Location: Ely, UK

View user's profile Send private message Visit poster's website

PostPosted: Tue Apr 19, 2011 4:14 am     Reply with quote

Hi PCM programmer.

Thank you for your reply.

I did submit a reply yesterday, but it didn't get posted for some reason? It's not the first time I've had a post disappear into oblivion Confused

I'm still using version 4.108. I'll try using the UART example you suggested, but I think I'll need to upgrade the compiler.

Andrew
_________________
Kind regards

Andrew Ellis
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Apr 19, 2011 5:39 am     Reply with quote

Quote:
but I think I'll need to upgrade the compiler

I only checked in MPLAB simulator, that versions before V4.110 don't generate UART output, so apparently SFR addresses or initialization are incorrect.

As PCM programmer suggested, you are still able to access the hardware UART in your own code, using SFR definitions of the PIC16F1827 datasheet..
AJEFenConsultancy



Joined: 09 Sep 2010
Posts: 11
Location: Ely, UK

View user's profile Send private message Visit poster's website

PostPosted: Thu Apr 21, 2011 5:08 am     Reply with quote

After a bit of haggling, I managed to get CCS to upgrade my compiler. So my problems are now resolved Very Happy
_________________
Kind regards

Andrew Ellis
lscantillo



Joined: 02 Apr 2017
Posts: 13

View user's profile Send private message

PostPosted: Sun Apr 23, 2017 5:54 am     Reply with quote

AJEFenConsultancy wrote:
After a bit of haggling, I managed to get CCS to upgrade my compiler. So my problems are now resolved Very Happy


what was your final code?
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