Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] dsPIC30F4011 - UART with internal oscillator

Status
Not open for further replies.

K33rg4t3

Full Member level 3
Joined
Aug 2, 2015
Messages
165
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Activity points
2,607
Hey guys
The question is simple
Is UART working with dsPIC30F4011 but with INTERNAL OSCILLATOR?
I mean UART2_Init, UART2_Write_Text, etc.
Do I have to use external eg. 20MHz or so oscillator or will it work with internal??
Thanks in advance
 

Any baudrate. Just want it work without oscillator, because I have already done PCB and I must use UART2 communication.
 

With the UART functions you have mentioned it seems that you are using mikroC PRO dsPIC Compiler. If 4800 or 9600 bps baudrate is enough then you can easily try internal 4 or 8 MHz Oscillator.
 

I think the question means "does it use the internal clock or require an external one?"

Answer: Yes, the UARTs use a shift clock derived from the internal Baud rate generators which in turn are fed from the internal clock. See section 18.8 of the data sheet.

Brian.
 

@betwixt

Does that mean that even if you use external Crystal it will use internal Oscillator for baudrate generation ?
 

It does not work no matter what I do.

Code:
char uart_rd;

void main() {
  ADPCFG = 0xFFFF;       // Configure AN pins as digital I/O

  UART2_Init(4800);               // Initialize UART module
  Delay_ms(100);                  // Wait for UART module to stabilize

  UART2_Write_Text("Start");
  UART2_Write(13);
  UART2_Write(10);

  while (1) {
      UART2_Write_Text("Start");                // Endless loop
      Delay_ms(1000);                  // Wait for UART module to stabilize
  }
}

Hyperterminal is receiving garbage.
DO I have wrong flags set??
dontknowhattosetdspic.png
 

What is ERC ? External RC Oscillator ?

You are Configuring Primary Oscillator Mode to External RC type and trying to use Internal Oscillator ?
 

I have tested several settings and none of them works correctly.
FRC w/PLL x8 does not work too...I dont know how to select the appropriate.
 

mikroE has a support. Submit a ticket. If it is Compiler bug then they will fix it.
 

I don't think its' a bug, I think I don't know how to set correctly the config bits...
 

Thare are 5 pages of information in the data sheet on how to configure the clock (p139-p144). For something that needs fairly precise timing like serial comms, using an external resistor/capacitor oscillator isn't appropriate.

Brian.
 

Thare are 5 pages of information in the data sheet on how to configure the clock (p139-p144). For something that needs fairly precise timing like serial comms, using an external resistor/capacitor oscillator isn't appropriate.

Brian.

There is mentioned a "FRC 8 MHz internal RC oscillator" setting ("FRC"), without any PLL, but I have only FRC+PLL settings in mikroC...


Also do you mean that it's better to use internal oscillator for precise timing???



EDIT: In that configuration field for MHz, do I have to enter 8MHz (before PLL) value, or after PLL?
 

Try the attached project. See if it prints "Start" on UART Terminal.

FRC frequency is fixed at 8 MHz and I have used FRC with 4x PLL. it means 8 MHz x 4 = 32 MHz System Clock. In the Clock frequency you have to mention 32 MHz.
 

Attachments

  • UART.rar
    47.5 KB · Views: 151

FRC frequency is fixed at 8 MHz and I have used FRC with 4x PLL. it means 8 MHz x 4 = 32 MHz System Clock. In the Clock frequency you have to mention 32 MHz.

I does not print at all, you have set "Internal Low power RC" and not "Internal Fast RC".
Anyway, I've tried rebuilding the hex, changing RC to Fast, and changing baud rate to 9600, but still no luck (trash data in Terminal).
 

Trash data means incorrect baudrate. baudrate for your COM port in PC and also in your Serial Terminal Software should match with the baudrate in code.
 

They do. I know it. The timing is wrong.
 

Hi,

you need to generate a baud rate with a max error of +/- 2%.

from 8MHz to 9600baud it means you need to divide the clock by 833.333 wich is not possible. you need to use 833.

Maybe you need to generate multiple of the baud rate, lets say 8x, then you need 104.167 --> 104.

****
now calculate back:
9600 baud x 8 = 76800 Hz
76800 Hz x 104 = 7987200 Hz.

max clock freq: +2% => 7987200 Hz * 1.02 = 8146944 Hz
min clock freq: -2% => 7987200 Hz * 0.98 = 7827456 Hz

--> If the RC oscillator can ensure that the actaul clock frequency is between those two limits, then transmission should operate without problems.
In all cases: supply voltage variation, aging, temperature variation...

I doubt that. But datasheet will tell you.

Klaus
 
Ok so I NEED TO USE EXTERNAL CRYSTAL.
But which crystal should I use?
20Mhz?
12Mhz?
http://wormfood.net/avrbaudcalc.php
This table says that even 8MHz is OK (eg. for 300) so I dont get it.

- - - Updated - - -

I HAVE GAVE UP.
It seems it's really not possible to get UART running with internal oscillator.
I have connected 16MHz crystal, changed the config and it started working IMMEDITELLY.
WORKINGdsPIC30.jpg

so, I am thinking that using UART withi nternal oscillator on dsPIC30F4011 is not possible, but if anybody has any suggestions, just tell me
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top