Continue to Site

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.

Programming

Status
Not open for further replies.
Nigel Goodwin said:
Yes, as long as you choose the uC that you wrote the code for! :p

I can't think of any reason you couldn't write a makefile for sdcc which would allow this. It would be a major pain in the neck if the uCs are very different, though.

I would think of it as more of a neat trick than something you'd want to actually do. And it certainly would be easier for a beginner to just rewrite the code for each target uC. It might be realistic for a large codebase which needs to have the ability to use newer versions of an architecture while maintaining compatibility with existing/older ones. Then again, it might not*. :)


Torben

[Edit: *: Then again #2: but that's not really the same thing as having one codebase target i.e. AVR, PIC, and Z80 anyway.]
 
Last edited:
well if i choos a PIC family (i.e PIC16FXXXX) does they have the same set of instructions? When using C code?
 
Well...

Kryten said:
Is it possible to make a program and choose uC afterwards?

Yes definitely...

See two cases are there...

if you write in c language then you can change your microcontroller whenever you want... from pic to avr to zilog to anyone...

when you want to choose a microcontroler among any of the pic then you can write the program in both assembly and C and then can choose the microcontroller...

All you need is to change the include (header) file on changing the controller...

Regards,

Simran..:)
 
Ok well i see i need to specify my questions better :)
This is what i asked on the top !!
;)

Edit:
What program do you sugest for making the firmware??
 
Last edited:
Kryten said:
Ok well i see i need to specify my questions better :)
This is what i asked on the top !!
;)

Actually, that's not the question you asked. You asked about microcontrollers in general, not PICs specifically. And the answer is only partly correct: if you write code depending upon features present in the higher-end PICs but not in the lower-end ones, that code will not work properly in lower-end PICs, regardless of the include file.

You can write code targetted at a range of uCs, as long as the code works within spec on all of them. Writing code which could run equally well on an 8051, a PIC, or an ATMEGA would be worth it only if the program didn't rely on any of the advanced features of any of the uCs. Choose the environment and code to it.

Within a family (like PICs) you could do some makefile magic to make it work, but I don't think it would be worth it.


Torben
 
You need to bear in mind that while C is far more portable than assembler, it's not really that portable, particularly for micro-controllers, where their specific requirements modify the language accordingly.
 
Nigel Goodwin said:
You need to bear in mind that while C is far more portable than assembler, it's not really that portable, particularly for micro-controllers, where their specific requirements modify the language accordingly.

A far more concise and elegant way to say what I was trying to say.


Torben
 
Well...

Well Sir,

I feel it is a good habit of using the assembly language... C is a good language but at least you have to master one industry microcontroller first... hence start with assembly...

Regards,

Simran..
 
Yes sir Simran. In school we have used ASMide with the MC68HC11 (thats with Assembly code)
So am familiar with assembly coding..
Have just started C programming now the easy stuff such as definng the different Analog inputs and setting the AD converter on them
 
Torben said:
Actually, that's not the question you asked. You asked about microcontrollers in general, not PICs specifically. And the answer is only partly correct: if you write code depending upon features present in the higher-end PICs but not in the lower-end ones, that code will not work properly in lower-end PICs, regardless of the include file.

You can write code targetted at a range of uCs, as long as the code works within spec on all of them. Writing code which could run equally well on an 8051, a PIC, or an ATMEGA would be worth it only if the program didn't rely on any of the advanced features of any of the uCs. Choose the environment and code to it.

Within a family (like PICs) you could do some makefile magic to make it work, but I don't think it would be worth it.


Torben

Ok Torben. (sounds like your a Norwegian bloke)
Im aiming at using the PIC16 family as i need a ADC that has hig resolution cos im measuring 100A @ 2.5V (hmm must aplify it a bit ) :p
 
Kryten said:
Ok Torben. (sounds like your a Norwegian bloke)

My mother is Danish, my Dad is Texan, and I'm from northwest Canada. I've been to Norway and loved it, though. And I'm wearing a cable-knit sweater right now. :)

Im aiming at using the PIC16 family as i need a ADC that has hig resolution cos im measuring 100A @ 2.5V (hmm must aplify it a bit ) :p

Sounds neat. What are you measuring?


Torben
 
Torben said:
Sounds neat. What are you measuring?
Torben

Im measuring the amout of energy going to and from a batterybank (made by a windmill) in order to figure out if there is need for aditional chargeing capasity. I also need to logg and mediate the measurments to a SD card
 
Kryten said:
Im measuring the amout of energy going to and from a batterybank (made by a windmill) in order to figure out if there is need for aditional chargeing capasity. I also need to logg and mediate the measurments to a SD card

Nice! Be sure to post your final results.

What is the budget for this project? There are things out there called SBCs (single-board computer) and SOMs (system on module) which include a processor and several peripherals such as serial, USB, and I/O ports; SD card drives; higher-resolution ADCs etc--but the ones I know about start at around $100 US. Depends on your budget and how much of it you want to do yourself, really.


Torben
 
Im looking to everything my self (this beeing a school procject the final one (Im a engineer this summer :D)) So i have to do as much as i can in limited time..

Well i have allegro shunts (samples) so I dont think this will be a huge cost in making it. I will ofcorse make everything available when its finished (and i bet a lot that the code will be seen on the forums here befor then).

Edit:
I think I have a SBC laying around some where at home ;)
 
Kryten said:
Im looking to everything my self (this beeing a school procject the final one (Im a engineer this summer :D)) So i have to do as much as i can in limited time..

There you go. Sounds like you have the chip you want and the motivation to use it. :)

Good luck with the rest of the school year!


Torben
 
Anybody that has any experisence with making a txt file and adding to it? (on a SD/MMC card or via SPI)
 
I dont think i understand what you mean?

My question (explained) Does anyone have any experience with (using a PIC) putting data in to a txt file and save it to a SD/MMC card. Then open it to add more data to it?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top