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

PIC16F917 serial output not displayed
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
POPE19



Joined: 27 Jun 2017
Posts: 71

View user's profile Send private message

PIC16F917 serial output not displayed
PostPosted: Mon Aug 07, 2017 10:30 am     Reply with quote

Hello,

I am using PIC16f917 to display output on serial monitor of CCS compiler. I am using PCWH 5.074 compiler. Earlier I have tried to display output using pic16f887 prototype board using usb to ttl cable. I am getting output there but i am not getting output with same code for 917 pic.

My connections are as follows:

USB to TTL Cable pic

GND GND
TXD pin26 (C7)
RXD pin25 (C6)

My code is as follows:
Code:

#include <16F917.h>
#fuses HS, MCLR, NOWDT, PUT, NOIESO, BROWNOUT, NOFCMEN
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void main()
{
 
  while(TRUE)
  {
    printf("\r \n hello");
  }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 11:44 am     Reply with quote

Do you know if the PIC is even running ? Have you tested it by blinking
an LED ? Does it blink at the expected frequency ?
temtronic



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

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 12:13 pm     Reply with quote

what PCM P says

also...
you may have to disable other internal 'peripherals' attached to those pins.

and...
I'd put a
delay_ms(1000);
after the print to slow down the data rate to the PC.

Jay
POPE19



Joined: 27 Jun 2017
Posts: 71

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 1:07 pm     Reply with quote

YES IT IS pcm PROGRAMMER . i WOTE FOLLOWING CODE AND THE LED IS BLINKING EVERY SEC. But there is no output on serial monitor.

Temtronic i dont understand what do you mean by internal peripherals. I have not connected anything to pin C6 & C7.
Code:


#include <16F917.h>
#fuses HS, MCLR, NOWDT, PUT, NOIESO, BROWNOUT, NOFCMEN
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define led PIN_D7

void main()
{
 
  while(TRUE)
  {
    output_low(led);
    delay_ms(1000);
    output_high(led);
    delay_ms(1000);
    printf("\r \n hello");
  }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 1:31 pm     Reply with quote

So give us a part number or link to the cable you are using, so we can see whether it has any oddities.
Have you tested it works (loop TX back to RX)?.
What terminal program are you using?.
POPE19



Joined: 27 Jun 2017
Posts: 71

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 1:36 pm     Reply with quote

Its TTL-232R-RPI -----> TTL to USB cable.

I don't know how to test loop TX back to RX
and I am using CCS V5.076 compiler and watching output in the serial monitor in tools of the compiler.

This cable works good when i use the same program on CCS PIC16F877 Prototype board, but when i am using it for PIC16F917 on breadboard its not displaying anything. I don't know what I am missing.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 1:48 pm     Reply with quote

That is a USB to _3.3v_ logic cable.

From it's data sheet:
"This cable is electrically configured to process and drive +3.3 V logic level UART signals.",

To be operating at 20MHz, you must be running your PIC off something over 4.2v.

Wrong......

Also the unit is programmable to provide signal inversion or not. Do you know how yours has been configured ? If not, you need to get the tools to configure this.
temtronic



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

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 1:55 pm     Reply with quote

OK, I googled "TTL-232R-RPI" and got a PDF for a 'Raspberry PI compatible " module.
from the PDF, page 2...
TTL-232R-RPi
USB to UART, 3.3V TTL logic level, Raspberry Pi compatible flying leads
...

It is a 3 volt device so that is probably the problem.
You've got a 5 volt PIC and a 3 volt module.

It's kind of misleading, as it has 5 volt 'tolerent' pins, meaning it will not burn up if 5 v is applied (on first page). The problem is that it cannot send a 5 volt logic level signal TO the PIC (on second page).

Loopback is a term used to descibe when the TX and RX of a device are tied together. So when you type a key on the PC keyboard it gets sent to the module, out the TX pin 'loops back' the RX pin and then is displayed onto the PC screen. I'm confident the TTL USB module will work in 'loopback' mode, but you need to try it to confirm it will.

If it passes that test, then it's the classic 5 volt PIC vs. 3 volt device problem. Usually a 'TTL' device needs to see 80% of VDD to see a logic '1', so 80% of 5 is 4 volts. The TTL-USB module can only supply a max of 3.2 volts, so the PIC will not see that as a '1'.

Jay
POPE19



Joined: 27 Jun 2017
Posts: 71

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 2:13 pm     Reply with quote

Thanks for explaining guys.

Jay ya you are right. It works in loopback, so this unit will not work. Can you please share the part no. or the link of the device i can use for the same purpose.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 2:18 pm     Reply with quote

I would though, have expected it to work for his current 'output' test.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 2:50 pm     Reply with quote

Hi Pope19,

You've got to learn to troubleshoot and problem solve on your own without just reflexively asking the forum for help. Why not just Google "USB to 5V TTL Converter" and see if you come up with something useful.....

Good Luck,
_________________
John

If it's worth doing, it's worth doing in real hardware!
POPE19



Joined: 27 Jun 2017
Posts: 71

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 3:21 pm     Reply with quote

I googled it first but end up buying this. And reason behind for asking is if I got stuck I can get feedback since experts in this groups are already using this and can be rectified easily if people have same device. I am not asking reflexively. I am a newbie and learning. This does not mean I am not finding answers on my own and just asking directly here in forum.
temtronic



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

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 4:38 pm     Reply with quote

Hmm.. I found it at Digikey.CA , here in Canada for $21, Yikes, I can buy (and have) 10, yes, TEN, of the basic, generic USB<>TTL modules for that price.
Hopefully it hasn't been damaged or partially reprogrammed (FTDI does show how...)
Have to admit it _should_ transmit to PC fine from PIC, so it if 'loopbacks' fine, then I suspect either the PIC or PCB has a problem. Perhaps a solder 'whisker' on the PIC TX pin has grounded it?

Try coding a 1Hz LED program using the same pin, use an LED and 470r in series to test and confirm the pin works as a digial output.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue Aug 08, 2017 2:45 am     Reply with quote

Now, as already said, your cable should work for the serial output. So something is wrong in the hardware.

However long term, this will give problems when working with a 5v PIC if you want to use it for input.

A look at the FTDI site:
<http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm>

Gives how many internal versions they actually produce!...

The ones that mention '5v UART signalling' are the ones that are directly compatible with a 5v PIC.

The one you have is the version custom designed to talk to the Raspberry Pi, with 3.3v outputs, but 5v 'tolerant' inputs, not a generic design.

Do you have any form of test equipment?. Meter, scope?.
POPE19



Joined: 27 Jun 2017
Posts: 71

View user's profile Send private message

PostPosted: Tue Aug 08, 2017 4:42 am     Reply with quote

Ttelmah,
Yes I have a multi-meter and an oscilloscope too. Please suggest something so that I can check.

Temtronic
I have tried blinking led at 1hz on both pins (C6 & C7) individually. Look like the PIC digital output is good. The led blinks at the same frequency as it was earlier on PIN_D7.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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