EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Visual Studio C++ to PIC

Started by Ryan June 7, 2004
Hi,
I'm attempting to compile my C++ application for a PIC
microcontroller.  I've been told that this can be done, though I'm
honestly not sure how to go about doing it.  I'd assume I either need
a special compiler or some sort of cross-compiler for the specific PIC
architecture.  However, I have a feeling that my problems will
increase even once I get it to compile and run on the microcontroller.
 For example, the application currents reads in a file from the local
disk...what will need to be done to read that same data from some sort
of flash memory?
If you have any suggestions, hints, tips, books, etc that could point
me in the right direction I'd really appreciate it.
Thanks in advance for your help,
--Ryan

Feel free to email me as well.
ryanscheller(at)comcast.net
Ryan wrote:

> Hi, > I'm attempting to compile my C++ application for a PIC > microcontroller. I've been told that this can be done, though I'm > honestly not sure how to go about doing it. I'd assume I either need > a special compiler or some sort of cross-compiler for the specific PIC > architecture. However, I have a feeling that my problems will > increase even once I get it to compile and run on the microcontroller. > For example, the application currents reads in a file from the local > disk...what will need to be done to read that same data from some sort > of flash memory? > If you have any suggestions, hints, tips, books, etc that could point > me in the right direction I'd really appreciate it. > Thanks in advance for your help,
That definitely won't work. A usual approach is to have the VC++ IDE, use the syntax sensitive editor and have a PIC C Compiler do the code. Rene -- Ing.Buero R.Tschaggelar - http://www.ibrtses.com & commercial newsgroups - http://www.talkto.net
Ryan <scheller@student.umass.edu> wrote:
> Hi, > I'm attempting to compile my C++ application for a PIC > microcontroller. I've been told that this can be done,
Whoever told you that has either been pulling off a cruel joke on you, or he's been wilfully obscure in talking to you, or he has no idea what he's talking about. Whatever it was, he deserves some serious retaliation --- so start planning a nasty one right away. While there may be some combination of stunted meanings of "C++ application", "compile for a PIC ", and the purported role of MSVC++ in all of it, where the above may actually be possible, stated as it is it's simply utter BS. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.

Ryan wrote:

> Hi, > I'm attempting to compile my C++ application for a PIC > microcontroller. I've been told that this can be done, though I'm > honestly not sure how to go about doing it. I'd assume I either need > a special compiler or some sort of cross-compiler for the specific PIC > architecture. However, I have a feeling that my problems will > increase even once I get it to compile and run on the microcontroller. > For example, the application currents reads in a file from the local > disk...what will need to be done to read that same data from some sort > of flash memory? > If you have any suggestions, hints, tips, books, etc that could point > me in the right direction I'd really appreciate it. > Thanks in advance for your help, > --Ryan > > Feel free to email me as well. > ryanscheller(at)comcast.net
Simply No You can get a C Compiler for a PIC. (i hear CSS is recommended) a PIC is 8 bits, a PC 32bits. A PIC (or 8051,or AVR) does not have the horse power to to do big things fast. There is no files system you can store stuff in flash as some type of array or data structure. If you wrote your program in straight ANSI C you maybe be able to port it to a PIC. If you made extensive use of the windows libs, maybe an embedded WinCE board?
Ok, I'm starting to understand, I think. 
Good news it, my C++ program does not use any windows libs.
I understand that I need a specific compiler for the microcontroller
architecture.  Sounds like most of them are for C and not C++, is this
true?
My application reads in an image file (jpeg) from the file system
(cwd), and does some "stuff" to it.  I'm still very foggy as to what
type of microcontroller and memory would facilitate this.  Any
suggestions?  I don't have to use a PIC, that's just the only one I'm
familiar with right now.  If there are some chips out there with some
type of memory that would make this easy on me, please point me in
that direction.
Thanks so much for your help!
--Ryan

ryanscheller(at)comcast.net
Ryan <scheller@student.umass.edu> wrote:

> My application reads in an image file (jpeg) from the file system > (cwd), and does some "stuff" to it.
You almost certainly don't want to do anything like that on a PIC. Or anything smaller than a rather powerful 16-bit MCU, for that matter. You'll have to clarify what you're trying to do, before it becomes viable to discuss choice of platforms or prorgramming languages. For starters: does it absolutely have to be JPEG, of all possible file formats? -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
> You almost certainly don't want to do anything like that on a PIC. Or > anything smaller than a rather powerful 16-bit MCU, for that matter.
Ok, good to know.
> You'll have to clarify what you're trying to do, before it becomes > viable to discuss choice of platforms or prorgramming languages.
Basically, I want to have a digital camera output the image it creates to some sort of memory that I can access it from the MCU. Then my application would read the image, and essientially read through the file and return rgb values for certain locations. I've got C++ code I wrote that reads a jpeg, returns rgb values, etc. I could probably port my C++ to C, and then use a specific compiler for whatever MCU I go with. Would that be ok?
> For starters: does it absolutely have to be JPEG, of all possible > file formats?
I suppose it doesn't absolutely have to be, however I'm thinking that most digital cameras write in jpeg. Does the format of the matter?
In article <1edcb178.0406080550.14791206@posting.google.com>, Ryan
<scheller@student.umass.edu> writes
>Ok, I'm starting to understand, I think. >Good news it, my C++ program does not use any windows libs.
This is irrelevant. there is no C+ compiler for PIC, AVR etc (there was one for there 8051 but it was little use)
>I understand that I need a specific compiler for the microcontroller >architecture.
I suggest you do a little more learning before you start to write programs. A compiler is a translator from a High level language to machine code. Different processors have different machine code.
>Sounds like most of them are for C and not C++, is this >true?
There are no C++ compilers for 8 bit processors. There are some EC++ compilers for 16, 32 but processors.
>My application reads in an image file (jpeg) from the file system >(cwd), and does some "stuff" to it.
No it does not and nor will it ever given your comments earlier. Sorry. You have much to learn. Embedded development is 50% software, 50% hardware and 50% systems. Start with some simple programs to learn about the system and programming. The program you have suggested is not trivial especially for some one who needs to learn the very basic stuff.
> I'm still very foggy as to what >type of microcontroller and memory would facilitate this. Any >suggestions? I don't have to use a PIC, that's just the only one I'm >familiar with right now.
It can't be a PIC. It does not have the power. It could be an 8051 but you don't have the experience of embedded programming yet. I know of a couple of commercial cameras that use a 51! (not my choice for it!) However something 16 bit would be better
> If there are some chips out there with some >type of memory that would make this easy on me, please point me in >that direction. >Thanks so much for your help!
You need to do a 101 embedded course first. You can't dive straight in at the level you are trying to. Start small and work you way up. This may be hard to take when you are full of enthusiasm but you need a learning curve to climb not a vertical cliff to run into. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Chris Hills <chris@phaedsys.org> writes:

> In article <1edcb178.0406080550.14791206@posting.google.com>, Ryan > <scheller@student.umass.edu> writes > >Ok, I'm starting to understand, I think. > >Good news it, my C++ program does not use any windows libs. > > This is irrelevant. there is no C+ compiler for PIC, AVR etc (there was > one for there 8051 but it was little use)
Actually I think that gcc-avr will do C++. Not that I would suggest actually using an AVR for this! -- John Devereux
scheller@student.umass.edu (Ryan) writes:

> Ok, I'm starting to understand, I think. > Good news it, my C++ program does not use any windows libs. > I understand that I need a specific compiler for the microcontroller > architecture. Sounds like most of them are for C and not C++, is this > true? > My application reads in an image file (jpeg) from the file system > (cwd), and does some "stuff" to it. I'm still very foggy as to what > type of microcontroller and memory would facilitate this. Any > suggestions? I don't have to use a PIC, that's just the only one I'm > familiar with right now. If there are some chips out there with some > type of memory that would make this easy on me, please point me in > that direction. > Thanks so much for your help!
I think that you will be struggling to shoehorn this application into a single-chip solution!. Your best bet would probably be an evaluation board / reference design for a 32 bit CPU, that comes with plenty of external RAM. Perhaps an ARM based system so you could use the free gcc c++ compiler. You could then copy the part of the reference design that you use, if you ever get that far... However this is non-trivial for your apparent hardware skill level. On the bright side, by the time you learn how to do it you will be able to get it as a single chip, so you won't have to :) -- John Devereux

The 2024 Embedded Online Conference