| View previous topic :: View next topic |
| Author |
Message |
andys
Joined: 23 Oct 2006 Posts: 175
|
| rs232 software |
Posted: Mon Dec 24, 2012 9:16 am |
|
|
But how to test with accuracy that the led is turn on/off for 1/2 second (i need an oscilloscope for this and i have not one ).
There is any other way to take this measure???? |
|
 |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Dec 24, 2012 9:47 am |
|
|
Hi andys,
Well, you could change the On and Off delays to 1 second, or something that
is more easily timed with a watch? This isn't rocket science, if you
can't more-or-less estimate that your PIC is operating at the correct speed
with the 'LED Test', you might consider throwing in the towel on this whole
project.....
Seriously, three pages to get a serial communications project working
suggests that you haven't fully engaged your brain on this project
John |
|
 |
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Mon Dec 24, 2012 10:57 am |
|
|
Just count it for 10 seconds - you are typically not going to find it off a little bit - either it will be close enough you can't detect the error by counting or it will be off by LOTS and be obvious.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
 |
andys
Joined: 23 Oct 2006 Posts: 175
|
| rs232 software |
Posted: Tue Dec 25, 2012 8:10 pm |
|
|
Finally now sent data to the screen.
Unfortunately instead to see what i print ( puts("A"); printf("HELLO");) to the code i see stranger characters.
how to fix this? |
|
 |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Dec 25, 2012 9:02 pm |
|
|
Hi,
You never confirmed for us that your PIC was operating at the correct speed!
If it's not, the baud rate of the serial transmission will be off and you'll see
garbage data being transmitted. You must verify that your PIC is running
at the correct speed - this has been covered countless times in the
forum!
Good Luck!
John |
|
 |
andys
Joined: 23 Oct 2006 Posts: 175
|
| rs232 software |
Posted: Wed Dec 26, 2012 3:33 pm |
|
|
Now the led turning Off for around 1/2 second, and On for around 1/2 second but the character which i see to the pc's screen is not what i sent it.
What else i have to change???? |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9658 Location: Greensville,Ontario
|
|
Posted: Thu Dec 27, 2012 8:32 am |
|
|
Well you're making progress,slowly.
Time to repost your current program...as well as the name of what 'terminal emulator' you're running on the PC. |
|
 |
andys
Joined: 23 Oct 2006 Posts: 175
|
| rs232 software |
Posted: Thu Dec 27, 2012 9:06 am |
|
|
I use the putty program.
The update code is presented below. What I need to change?
| Code: |
#include <33fj128GP802.h>
// Device Specification
//#fuses HS // Oscillator mode HS
//#fuses XT
#fuses NOWDT // No Low Voltage Program, No Watchdog timer
#fuses NOPROTECT // Code no protection
#use delay (clock=8000000) // Use built-in function: delay_ms() & delay_us()
#PIN_SELECT U1TX=PIN_B14
#PIN_SELECT U1RX=PIN_B15
#USE RS232(UART1,ERRORS,BAUD=9600)
void main()
{
//char s[6]="HELLO";
while(1)
{
puts("AAAA");
printf("HELLO");
//puts(s);
//puts("\n");
output_low(pin_A0);
delay_ms(450);
//delay_ms(300);
puts("KK");
//puts("\n");
output_high(pin_A0);
//delay_ms(300);
delay_ms(450);
//putc(13);
}
}
|
|
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Dec 27, 2012 10:37 am |
|
|
Great andys !!! your circuit is alive and doing something.
I never used this MCU, and I do not know some important details of your wiring, please could you tell us:
1) if you are using the internal built-in oscillator
2) or a real crystal with 2 small capacitors connected across the OSC's pins.
3) the voltage at Vdd pin.
4) in your code there is not a valid #fuse directive, this is an important issue in order to tell the compiler to code the correct PIC fuses (bits) in the Configuration Register.
Humberto |
|
 |
andys
Joined: 23 Oct 2006 Posts: 175
|
| rs232 software |
Posted: Thu Dec 27, 2012 11:31 am |
|
|
1-2)I am using microstik2 (and i using from the programming platform) so i did not but any external crystal
3)votage at Vdd is 3.3v
4)For Fuses the HS is for high speed ans XT for crystal , what is the fuse for internal oscillator?
what is the better for this application ??? |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Dec 27, 2012 12:46 pm |
|
|
In your Preprocessor Directives there is not any #FUSES type defined for MCU oscillator configuration code.
| Code: |
// Device Specification
//#fuses HS // Oscillator mode HS
//#fuses XT
|
Microstik2 do not have any crystal on board, hence you must use the Internal RC buit-in oscillator module.
The configuration code should look like this:
| Code: |
#include <33FJ128MC802.h>
#FUSES NOPROTECT //General Segment Code not Protected
#FUSES PR_PLL //Primary Oscillator with PLL
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOWDT //No Watch Dog Timer
#use delay(clock=8000000)
|
Humberto |
|
 |
andys
Joined: 23 Oct 2006 Posts: 175
|
| rs232 software |
Posted: Thu Dec 27, 2012 4:12 pm |
|
|
Humberto i tried to use the fuses that you suggest me but nothing is working.
(neither led and messages to pc).
Currently i use dspic33fj128gp802 and no dspic33fj128mc802. (I have both microcontrollers and i used your suggestions in both microcontrollers but none is working with these fuses). |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Dec 27, 2012 6:36 pm |
|
|
Did you include these lines in the test?
| Code: |
#PIN_SELECT U1TX=PIN_B14
#PIN_SELECT U1RX=PIN_B15
#USE RS232(UART1,ERRORS,BAUD=9600)
|
Humberto |
|
 |
andys
Joined: 23 Oct 2006 Posts: 175
|
| rs232 software |
Posted: Thu Dec 27, 2012 6:50 pm |
|
|
Yes the code which I used is presented below.
I can compile (make, build) without problems but when i download it to the microcontroller I can not see any results (leds or pc's screen).
| Code: |
#include <33FJ128GP802.h>
#FUSES NOPROTECT //General Segment Code not Protected
#FUSES PR_PLL //Primary Oscillator with PLL
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOWDT //No Watch Dog Timer
#use delay(clock=8000000)
#PIN_SELECT U1TX=PIN_B14
#PIN_SELECT U1RX=PIN_B15
#USE RS232(UART1,ERRORS,BAUD=9600)
void main()
{
while(1)
{
puts("AAAA");
printf("HELLO");
output_low(pin_A0);
delay_ms(450);
//delay_ms(300);
puts("KK");
//puts("\n");
output_high(pin_A0);
//delay_ms(300);
delay_ms(450);
}
}
|
|
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Dec 28, 2012 10:28 am |
|
|
Sorry, I can not help you in this way.
To learn coding C + PIC I suggest to start with the PIC16F84 or an equivalent 8-bit MCU, start coding the blinking LED test,
as suggested in this thread and learn how to handle software delays, configure hardware timers, interrupts, oscillator types,
how to send characters strings to PC and once you gain the skills to control your hardware, you can add functions gradually.
Usually, every time you made a relevant change in the source code, it is a good practice rename your source code in order
keep the last functioning version of your code, in such way that if the next test does not run, you can go back to the last
version that was working properly and start again. This is the way that I know, one step each time.
You are doing your first steps with a very complex and powerfull MCUs with 24-bit wide instructions just to use only .001 %
of its capacity, most of us never used it and most important, it does not contribute in this stage your learning.
I can not help you in this way. Sorry.
Humberto |
|
 |
|