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

Turn Led on - USB PIC
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 13, 2014 12:07 pm     Reply with quote

I don't have the CCS IDE, but I suspect, as Ttelmah does, that you are
not correctly assigning the project source files.

Can you post a screenshot of the Files window for your program ?
Here are some examples of the Files window:

This one is a close-up screenshot:
http://www.ccsinfo.com/images/newsdesk/navigation_panel.png

This one shows the whole IDE. The Files window is on the left side.
http://www.ccsinfo.com/content.php?page=ide_advantages

Post a screenshot of your Files window.
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Solution
PostPosted: Wed Aug 13, 2014 2:51 pm     Reply with quote

I just figured out what was the problem. I checked the files I was using, and for some strange reason it was using a different directory than the one in which the project resides in. I just closed the application and opened the app again, and it compiled just fine.
Thanks for all you help!

I have another question.
I made the led blink on a dev board I purchased and I think that I'm doing something wrong in the code, because it delays 4 times what its supposed to delay.

Code:

#include <18F4550.h>
#fuses HS,NOWDT,NOPUT,NOLVP,BROWNOUT,NOCPD,NOWRT
#use delay(clock=5000000)

void main()
{
   while (TRUE)
   {
   output_HIGH(PIN_A3);
   delay_ms(1000);
   output_LOW(PIN_A3);
   delay_ms(1000);
   }


Can someone please tell me how to fix this problem?
Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 13, 2014 4:12 pm     Reply with quote

Well, what's your crystal frequency ? The #use delay(clock= xxxx)
should match your crystal frequency, for the #fuse settings shown.
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Crystal Frequency
PostPosted: Wed Aug 13, 2014 5:48 pm     Reply with quote

I use a 20 mhz crystal, but for the app to work correctly, I used a delay(clock=5000000). I changed the delay, and the pic worked faster, and before it seemed to work 4 times slower.
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Tera Term
PostPosted: Fri Aug 15, 2014 10:22 am     Reply with quote

How do I send the 1 and the 0 using Tera Term?
Can someone please help me?
Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 15, 2014 10:46 am     Reply with quote

Just type it in. Start TeraTerm and press the 1 key. Then press the 0 key.
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Fri Aug 15, 2014 2:15 pm     Reply with quote

Simple....

CPUDIV1

The default is '11', for the two fuses unless you specify a value, so you get CPUDIV4
ezflyr



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

View user's profile Send private message

PostPosted: Fri Aug 15, 2014 6:53 pm     Reply with quote

Hi,

This thread is turning into a joke!

You are finally telling us on page three of a USB thread that you can't blink an LED at a predictable rate?? Dude, that is job #1 on any PIC project!

Learn to walk before you attempt to run, or your experience with PICs will surely be disappointing!

Out of curiosity, did you bother to read the '4550 datasheet? The Oscillator section, in particular, is *required* reading!

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 15, 2014 7:12 pm     Reply with quote

Ttelmah wants you to add the fuse shown in bold below
to fix your LED blinking program:
Quote:
#include <18F4550.h>
#fuses HS,NOWDT,NOPUT,NOLVP,BROWNOUT,NOCPD,NOWRT, CPUDIV1
#use delay(clock=20M)

void main()
{
while (TRUE)
{
output_HIGH(PIN_A3);
delay_ms(1000);
output_LOW(PIN_A3);
delay_ms(1000);
}
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Tera Term Error
PostPosted: Sat Aug 16, 2014 9:53 am     Reply with quote

I started tera term, but I can't send the 1 & the 0 to the pic.
I uploaded a video, so you can see what I mean.
In the video, the pic is listed as com 5.
https://www.mediafire.com/?jog4g92830em34a
The problem I was having with the time, was caused by an option I selected when creating the project, that was full speed usb.
I just created a blank source file and pasted the blink code with a 20 mhz frequency, and it worked just fine.
Now the only problem I'm having is with tera term.
Can someone please help me?
Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 16, 2014 10:43 am     Reply with quote

Go to the Setup / Terminal menu in TeraTerm and select Local Echo.
Then you can see what characters you are typing.
This won't fix your problem, but at least you can see what characters
you are sending.

Also, go to Setup / Serial Port and make sure that Flow Control is set
to "none".
temtronic



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

View user's profile Send private message

PostPosted: Sat Aug 16, 2014 12:52 pm     Reply with quote

For 'debugging' ANY USB project you MUST begin by confirming the PC works right.
You should BUY a $3 USB<->TTL module, configure IT as a 'loopback', THEN get your PC/terminal program working BEFORE you attempt any USB communications
AFTER that then cut a simple 'echo' program of the PIC, burn it, test. Get it to work 100%
THEN proceed with your real 'project'.

All of the above must be done in sequence or you'll spend hours if not days trying to figure it out. When I played with the 4550 years ago , it took me less than 2 hours to have my project 'up and running'.

hth
jay
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Fix
PostPosted: Sun Aug 17, 2014 7:56 am     Reply with quote

I finally got it working with tera term.
I created a blank source file, and pasted the code provided, but I changed the pin that's being used.
I used tera term terminal, found in setup to send the 1 to the pic, and to do so I had to select the local echo, because I couldn't see what command I was sending.
After doing that I connected a LED to the pin out, and to the ground, to try it out, and it finally worked.
Thanks for all your help, I really appreciate it!
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Pic + Java
PostPosted: Sun Aug 17, 2014 8:37 am     Reply with quote

I finally got it working with tera term, but now I would like to get it working with Java.
I'm using netbeans, and I found this page that's in english:
http://www.tecnohobby.net/ppal/index.php/electronica/microcontroladores/18-send-simple-data-from-a-java-application-to-a-pic18f4550-through-usb
I would like someone to help me out, because what I'm trying to do is send the instruction for the led to turn on or off, with the click of a button.
If someone gets this working in netbeans, could you please share your java project with me, so I can take a look at it, and I can get my app working?
The only thing that has to be changed is the numbers that are being sent, to 1 & 0, instead of 127 & 126, or this can be changed in ccs. It should work both ways.
This is the last request I have, please help me out with this.
Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 17, 2014 12:21 pm     Reply with quote

The 18F4550 USB code that I posted is looking for an ASCII '1' or '0'.
In hex format, that means it's looking for 0x31 and 0x30, or in decimal,
it's looking for 49 and 48.

That should give you enough information to modify your Java program.
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 Previous  1, 2, 3, 4  Next
Page 3 of 4

 
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