Jump to content

PIC programming.


Goblinz
 Share

Recommended Posts

I'm wanting to learn about PIC programming. I have no coding experience other than a bit of SAS and a little bit of basic (started to learn as a kid in the early 90's). Can anyone suggest any online resources which are easy to learn from, there seem to be quite a few out there and I'm sure that some are better than others. What language would be best to start learning with?

          G

Link to comment
Share on other sites

I assume learning asm or C would be best suited for PIC programming. C is nice to know, since it is widely used and you might put your newly acquired knowledge to good use in a lot of other projects as well. ASM would be good, since it only has a really tiny number of commands to choose from, it's can pretty annoying since you get punished for every tiny mistake you make =)

I'd probably start with a high-level language like C, C++ or ObjectPascal (Delphi IDE) or Java if I were you. There are great IDEs for all of these, they're fairly easy to learn (ObjectPascal probably even more than the others). And if you're familiar with one of them, learning another one is really not that big a deal, since they're all alike =)

Just my opinion though. And now - don't stone me please, you ASM and C gurus - I like Delphi more than any other language :D

Link to comment
Share on other sites

you can start programming C for PIC too...

First search in "MIOS programming" Subforum here... look after Threads about start programming or C Tutorial.. There you will find some hints/links about C Programming.

For installing:

If you work with Windows, best you install CodeBlocks (with install options described by stryd_one (look into Wiki and search after article codeblocks).

Then you have to copy the c skeleton from TK. After that take a look in Menu ->MIOS->Functions (it's a describtion about functions of MIOS, which you can use in your code).

PS: please post in e.g. MIOS programming next

Link to comment
Share on other sites

I'd probably start with a high-level language like C, C++ or ObjectPascal (Delphi IDE) or Java if I were you.

akkk! forget object pascal for pic (or any object oriented language for that matter)

in pic land, there's little benefit to objects and nowhere near enough program space...

java?! you have to be joking!

c is what you want.

btw, delphi used to be my favorite for windows programming, but now i'll take visualstudio first.

(hmmm look who's running the ms c# team...)

Link to comment
Share on other sites

I'll look at C then. Is it a case of just learning C or do you need to learn C for the PIC, Just trying to get my head round it all at them moment. Untill discovering ucapps I thought that PICs had to be programmed in their own special programming language! TBH i'm not looking at learning it for midibox purposes to begin with as I feel that will be a long way off, I'm wanting to start on something very simple and then maybe I'll be able to consider working with MIOS stuff in the future.

Stryd_one. I'm not even sure what code blocks are, I'm a complete newbie to this! I will be using windows so will probably be using codeblocks as asvised by Rio. No rush on updating the documentation as I've still got a long way to go, I think my first step will be building the PIC programmer as I need this for my midibox anyway.

Thanks for the advice.

              G

Link to comment
Share on other sites

Well when you compile your C application, it generates code in PIC ASM - which is that special language you spoke of ;)

Theoretically, C is the same for all platforms, although there are exceptions, and SDCC is one, although the basic syntax is the same, so if you learn C for your PC the knowledge will transfer to MIOS, no worries.

Code::Blocks is an IDE, which is basically a text editor on steroids. It will do things like syntax highlighting and autocompletion to help you write the code, and will interact with GDB to help with debugging your application. Don't worry about what these things all are, you'll soon find out when they are helping you :)

Link to comment
Share on other sites

native C Code will be written on all plattforms in same way...so learn C with several c_tutorials in internet or books first...

CodeBlocks IDE ( like Stryd_one mentioned ) can manage your projects, can administer your files and run the SDCC (Small Device C Compiler) to compile your sources to binaries (hex, bin), which you can upload on PIC later...

To upload/run an application on your PIC, you will need a complete Core Modul, A LCD will be recommended.. and a MIDI-IN Port (MIDI-OUT for check) + a MIDI<->PC device to transfer data with programs like MIDI-OX or MIOS Studio from PC.

Before you upload an programm, you need to upload MIOS first.

Best Regards, Rio.

Link to comment
Share on other sites

run the SDCC (Small Device C Compiler) to compile your sources to binaries (hex, bin), which you can upload on PIC later...

Just to avoid confusion... or maybe create it (doh) that's not completely true...

You write your code (*.c) and then it is complied by SDCC to output PIC assembly (*.asm)

Then the PIC ASM is assembled into object (*.o) files by GPASM

Then the .o files are linked using GPLink to make HEX files. These have the exact data that will be burned into the PICs program memory.

The the HEX files are converted to MIDIbox compatible SysEx (*.SYX). You only need this step if you are uploading by normal midi, most of the time these days we use the hex files with MIOS Studio, which converts them on the fly and also has the 'smart mode' to make uploading less error-prone.

This whole process is automated for you, you just need to run make.bat and it takes care of the rest.

If you use codeblocks, you can hit a button or keyboard shortcut, and it will run the make.bat for you. It also monitors the output of that script, so if SDCC finds an error in your code at line 99 column 10, it will automatically jump to the relevant file, and highlight the line with the error and tell you what's wrong with it (in a cryptic kind of way).

As I say, don't worry too much about all this, you'll undoubtedly 'get it' as soon as you try it :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...