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

dspic

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
balaji



Joined: 30 Mar 2010
Posts: 21

View user's profile Send private message Send e-mail

dspic
PostPosted: Thu Apr 29, 2010 7:26 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 29, 2010 8:46 am     Reply with quote

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

View user's profile Send private message Send e-mail

it works
PostPosted: Thu Apr 29, 2010 8:49 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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