View previous topic :: View next topic |
Author |
Message |
balaji
Joined: 30 Mar 2010 Posts: 21
|
dspic |
Posted: Thu Apr 29, 2010 7:26 am |
|
|
Hai All,
I am using dsPIC30F3011 for my project. I use UART2 for communicating my PC.
Code: |
#include <30F3011.h>
#use delay(clock = 4000000) // declaring osc frequency//
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES PR //Primary Oscillator
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES PUT64 //Power On Reset Timer value 64ms
#FUSES NOBROWNOUT //No brownout reset
//#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOCOE //Device will reset into operational mode
#FUSES ICSP1 //ICD uses PGC1/PGD1 pins
#FUSES RESERVED //Used to set the reserved FUSE bits
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#include <stdio.h>
#use rs232(UART2,baud = 4800)
#define TRISB = 0x02C6
#define TRISF = 0x02DE
void main()
{
set_tris_b(0x0000);
set_tris_f(0x0000);
while(1)
{
printf("hello");
output_high(pin_B0);
output_high(pin_F0);
delay_ms(1000);
output_low(pin_B0);
output_low(pin_F0);
delay_ms(1000);
}
}
|
The result is I'm always getting some repeated garbage value in Terminal window. I tried many baud rate in PC but still the result is same.
Pls help. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Thu Apr 29, 2010 8:46 am |
|
|
The obvious question is 'what is your oscillator frequency'. You have HS selected (which is for crystals > 10MHz), but the delay statement set to use 4MHz. Having this high gain mode selected, can result in the crystal locking onto the wrong frequency. Do a simple 'pulse a pin' test, operating it at (say) 1Hz, and see if the output is at the frequency you expect. This needs to be 'right', before trying serial I/O.
Best Wishes |
|
|
balaji
Joined: 30 Mar 2010 Posts: 21
|
it works |
Posted: Thu Apr 29, 2010 8:49 am |
|
|
Thank you sir for your reply.
I changed the MCLR comment and now it works.
I look guidance for Dual Uart. How to work on it.
pls help |
|
|
|