Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Starting dsPIC

Status
Not open for further replies.
Hey there,

I'm intending to start a simple, cheap dsPIC. Any recommendations?

Also, I have the PICKit 2, and I read that it could program a number of dsPICs.

On top of that, must I learn or relearn ASM for the dsPIC, or just directly use C? I had learned both C and ASM for PIC 16/18Fs, but I'm not sure about the dsPICs.

Opinions will be greatly appreciated. :)
 

kchriste

New Member
Forum Supporter
I'm intending to start a simple, cheap dsPIC. Any recommendations?
I used the dspic30f2020 which is available in DIP and works with 5V supply. There are probably cheaper ones out there like the dsPIC30F2011, etc. But obviously, the one you choose must be supported by the PicKit.
On top of that, must I learn or relearn ASM for the dsPIC, or just directly use C? I had learned both C and ASM for PIC 16/18Fs, but I'm not sure about the dsPICs.
You can use C though the ASM is quite different. Some example code here:
https://www.electro-tech-online.com/threads/hello-world-in-c-from-dspic30f2020.42185/
 
Last edited:
I used the dspic30f2020 which is available in DIP and works with 5V supply. There are probably cheaper ones out there like the dsPIC30F2011, etc. But obviously, the one you choose must be supported by the PicKit.
You can use C though the ASM is quite different. Some example code here:
https://www.electro-tech-online.com/threads/hello-world-in-c-from-dspic30f2020.42185/

Oh I see. Well, I don't have much knowledge of DSP - should I go read a little bit before really learning dsPIC, or I just will use the preloaded DSP libraries provided? :)
 

kchriste

New Member
Forum Supporter
It depends on what you want to achieve. If you really want to learn about DSP in depth, then you really need to study DSP and try programming in dsPIC assembler. But if you just want to get something done relatively quick, then C30 and one of the DSP libraries from MicroChip is the way to go. I didn't have too much trouble using their FFT libs:
https://www.electro-tech-online.com/threads/fir-fft-iir-on-dspic.92403/#post732904
 
Last edited:

Oznog

Active Member
Well, people often find the name "dsPIC" intimidating and get some misconceptions about it. Specifically, some people got the impression that it only executes DSP tasks.

The dsPIC runs C and assembly just fine. Its assembly set, running 16 bit math, is much more powerful than the 18F, certainly. It's a fine general-purpose processor too, more powerful than an 18F.

The thing which makes it a "DSP" is primarily the 40-bit Accumulator, the ability to run Fractional math, and a few assembly instructions which work really well for digital filters and such. If you don't need them, the 24F is basically the same as the 33F, 16 bit instructions, 3.3v silicon, but without the DSP bits, at a slightly reduced price. But you'd be surprised what "normal" tasks may benefit from using parts of the DSP engine.

NONE of the DSP engine will be invoked by normal C code. That is, you can write any C math (+-*/) in 16 bits or whatever but it won't use the Accumulator or Fractional-type math unless you write ASM (very easy on the 33F C compiler to jump to ASM) or use some built-in inline ASM calls from C that are something you haven't seen before.

The 30F is a 5V process, but it takes a LOT of power. You can even overheat a 30F chip running at full speed. The 33F's 3.3v silicon will not only run on much less power, it's capable of running significantly faster. The 33F (and the 24F) cannot take a 5v power supply at all. There are "5v tolerant I/O pins", which can take 5v as an input and can be open-drain outputs with external pullup resistors to an external 5v rail. 33F has much weaker current drive, the ones I know have 4mA max output as opposed to the 20mA you're used to in the 18F series (and the 30F is high current pins too).

The 33F has a DMA controller that the 30F does not have. DMA is pretty awesome when you need it. The peripherals can read or write straight into RAM, without interrupts or code intervention. It can do with the instruction core in Doze with some peripherals left on. This can really save a bundle of processing capacity with high-speed ADC or whatever.

33F and 24F have notably high minimum Sleep current in their spec. There is no way to get the current way down to "practically zero". This may be a problem for battery-driven stuff left off for extended periods.
 
Last edited:
I see. Well, just searched around for those dsPIC tutorials - they are really really obscure. Not like those 16/18F where they have tons of tutorials around online.

I need to keep searching some more. Haha. :D
 

kchriste

New Member
Forum Supporter
I think you are going to have to find a generic DSP tutorial. DSP is very math intensive and is more about applying mathematical formulas to sets of data than anything else. I don't profess to know much about it as far as the math is concerned. A general understanding of DSP techniques will help a lot when you go and try to use the DSP libraries from MicroChip or anyone else. I found myself studying the basics of FFT just to know which library was the best to use.
As Oznog pointed out, if all you want is 16bit computing power, then the cheaper 24F series will probably do what you want without any DSP at all. ie: You could run DSP routines on the 16F or 18F series, but it would be slow because the core isn't optimized for it.
 
Last edited:

Oznog

Active Member
Or you can use the 33F with the DSP features present and start by making it run standard C code.

Basically, what do you WANT to do with it? DSP can do lots of different things, but hard to recommend a tutorial without a goal. It can process audio, it can do active control of structures (Segway balancing), filters, all sorts of things.
 

bananasiong

New Member
You may need this (Programming 16-Bit PIC Microcontrollers in C). The tutorial for C30 are done pretty well even though it is written for PIC24.
 

Oznog

Active Member
The 30F, 33F, and 24F all use the same 16-bit instruction core (except for lack of the DSP bits on the 24F).
In fact, the libraries written for DSP ops on the 30F will run on the 33F. They've got the same DSP core.

Assembly which does not use the DSP core will generally run on any of the 3 families.

C code written for a 12F, 16F, or 18F won't have a problem on a dsPIC. For example, if you wrote an LCD driver for the 18F, that'll probably run on a 33F with minimal headache. The way interrupts are declared changes a bit, and of course the peripheral registers have changed. I think they made some minor tweaks to the syntax between 18F and 30F compilers, but that's a compiler thing.
 
kchriste - Oh I see. I will go to my college library and study about the rudiments of DSP first.

Oznog - Hmm... I love to do some envelope shaping, since it's part of the DSP thingy, and some simple equalizer hobby thing too. I have now made myself a cheap music box, but sans with a proper ADSR (Attack-Decay-Sustain-Release) filter, and by using a DSP, I guess that would be easy.

Bananasiong - That book is fantastic, judging by the previews in Google Books. I will get one of these if it's sold in the bookstore.
 

bananasiong

New Member
I don't know whether it is sold in Malaysia for now. You have to provide them the ISBN to order. It took me around 2 months to get it.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top