EEVblog® Electronics Community Forum
Electronics => Microcontrollers => Topic started by: Omrieinbar on December 22, 2019, 09:22:26 pm
-
I would like to program a microcontroller to control a DDS based function generator, I got a couple of PIC16F18875 micros, a PICKit 4 and a Microchip Curiosity HPC board to get me started. can anyone recommend a beginners guide to programming microcontrollers (Books\ Videos)?
They don't need to be specifically about a PIC16F18875 but I want to get a general idea for how to program PIC micros for future projects.
I already know how to use an Arduino and I don't want to use an Arduino for this project since I want to learn something new.
Also, A Raspberry pi is also not an option since I don't want to buy one, I know it is much more powerful but it also cost a lot more than a micro.
Thanks.
-
All you really need is a basic knowledge of C programming and the PIC datasheet.
Your program will read/write directly to the PIC registers.
You will need the datasheet for the register names and bit assignments.
The PIC16F18875 you choose will only allow you to do basic control for testing.
However, it does NOT have enough memory for your complete project.
In my Function Generator, I used a AD9834, MCP4812 and PIC18F2550.
I had used 95% of the PIC memory when finished. You will need at least 32M byte.
However, here are a few tutorials of general PIC programming:
And code for a PIC18F4520 to blink a LED:
-
Hi,
I don't know if a PIC16 is big enough for your project, but if you look, you can see that you can find PIC32MM or PIC32MX at same prices. So, don't waste your time with PIC16 and go directly to PIC32.
-
Hi,
I don't know if a PIC16 is big enough for your project, but if you look, you can see that you can find PIC32MM or PIC32MX at same prices. So, don't waste your time with PIC16 and go directly to PIC32.
Better move on to ARM then if you are going for 32 bit. And unlike many seem to think ARM doesn't have to be very difficult. Personally I find NXP's LPC series ARM controllers well documented an easy to use (relatively simple to program & use peripherals).
-
...
The PIC16F18875 you choose will only allow you to do basic control for testing.
However, it does NOT have enough memory for your complete project.
In my Function Generator, I used a AD9834, MCP4812 and PIC18F2550.
I had used 95% of the PIC memory when finished. You will need at least 32M byte.
However, here are a few tutorials of general PIC programming:
And code for a PIC18F4520 to blink a LED:
I do not get the notion the OP wants to build a DDS function generator
so much as control one, after all he wrote:
I would like to program a microcontroller to control a DDS based function generator, ...
( insert puzzled emoji here --- not )
ah, maybe the OP will clarify.
Thanks for the zip file with the awesome PIC Programming short course.
-
I would definitely recommend you to check application notes, they often show in very simple examples how to config the oscillator, handle the ports, using all kinds of peripherals, they have commented code to download and sometimes, some theory too.
Try to filter them to show only MPLAB X IDE (there are some old examples that would use retired libraries and compilers like hitech/ccs)
https://www.microchip.com/wwwcategory/taxonomysearch/ (https://www.microchip.com/wwwcategory/taxonomysearch/)
-
Thank you for your replies!
My function generator probably won't be based around the PIC16F18875, I thought of it as more of a intro to PIC programming as I don't know much about programming micros I'll see what I can accomplish on the PIC16F18875 and move on from there once I have a clearer picture of what I want the function generator to do.
If anyone have any more tips I will be glad to hear them.
-
Thank you for your replies!
My function generator probably won't be based around the PIC16F18875, I thought of it as more of a intro to PIC programming as I don't know much about programming micros I'll see what I can accomplish on the PIC16F18875 and move on from there once I have a clearer picture of what I want the function generator to do.
If anyone have any more tips I will be glad to hear them.
Some additional things to think about:
My Function Generator is based on the AD9834.
I choose it because I could use the 'FS_Adjust' pin to control the amplitud.
Also, I added additional capabilities not built into the AD9834.
- I implemented a frequency sweep, up and down, by updating the AD9834 from a fixed 500Hz interrupt in the PIC.
- I multiplexed the 'Sign_Bit_Out' pin with a PWM pin on the PIC. A PWM waveform is a nice ability to have.
You need to be careful not to drive both the 'Sign_Bit_Out' pin on the AD9834 and the PWM pin on the PIC at the same time.
The PIC18F2550 just barely met my requirements. One of the driving factors is the display graphics. I used a small OLED display and the graphics library used almost 50% of the PIC memory. A PIC18f2620 is another option with 64B of memory. If you use a display that needs to buffer the display memory, you will need a MCU that has a LOT of RAM memory.
-
As for learning C and more specifically MPLABX, Microchip has a tutorial site that covers a myriad of topics at:
https://microchipdeveloper.com/training-self:start (https://microchipdeveloper.com/training-self:start)
Also, as for the OLED display eating up bunches of memory, I've been playing with the Nextion displays (Nuts and Volts current issue includes an article on this). The Nextion IDE allows you to create the look & function you want while the built-in MCU takes care of all the memory needs:
https://www.itead.cc/display/nextion.html (https://www.itead.cc/display/nextion.html)