View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
nando88
Joined: 25 Aug 2013 Posts: 28
|
Solution |
Posted: Wed Aug 13, 2014 2:51 pm |
|
|
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
|
|
Posted: Wed Aug 13, 2014 4:12 pm |
|
|
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
|
Crystal Frequency |
Posted: Wed Aug 13, 2014 5:48 pm |
|
|
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
|
Tera Term |
Posted: Fri Aug 15, 2014 10:22 am |
|
|
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
|
|
Posted: Fri Aug 15, 2014 10:46 am |
|
|
Just type it in. Start TeraTerm and press the 1 key. Then press the 0 key. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Fri Aug 15, 2014 2:15 pm |
|
|
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
|
|
Posted: Fri Aug 15, 2014 6:53 pm |
|
|
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
|
|
Posted: Fri Aug 15, 2014 7:12 pm |
|
|
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
|
Tera Term Error |
Posted: Sat Aug 16, 2014 9:53 am |
|
|
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
|
|
Posted: Sat Aug 16, 2014 10:43 am |
|
|
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
|
|
Posted: Sat Aug 16, 2014 12:52 pm |
|
|
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
|
Fix |
Posted: Sun Aug 17, 2014 7:56 am |
|
|
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
|
Pic + Java |
Posted: Sun Aug 17, 2014 8:37 am |
|
|
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
|
|
Posted: Sun Aug 17, 2014 12:21 pm |
|
|
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. |
|
|
|