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.

PIC and MC ... can both use the same source code?

Status
Not open for further replies.

Zanna

New Member
hi..i'm actually very new to this microcontroller stuff...i'm currently doing a project on microcontroller-based gas detector..i found the source code for the program for thegas detector..i'm planning to program the PIC 16F877 however, the code is for the MC68HC908QT1 microcontroller..can the same source code be used?..or is there major difference in the code between these two microcontroller?
 
For sure the codes are not compatitble.
Try to search for code for PIC, i suppose you could find quite a lot PIC project on net.
 
sorry, but stupiddum is right... unlike desktop computers, which typically deal with high-level languages for programming, separating you from the hardware, microcontroller programming is very closely related to the hardware, especially when you're writing in assembly. even when using higher-level compilers (C, BASIC, etc), because of the nature of a microcontroller, you're still dealing pretty directly with hardware.

and the hardware of a PIC 16F877 is going to be very different from any motorola device.

at best, you could port the code, but that would take a fair amount of knowledge of both programming languages, at which point it would probably be easier to write it from scratch, or find something similar that's already written for an '877.

if you can at least get a general idea of how the code for the motorola chip is actually functioning, you can use that as a general outline for how to structure your program on the PIC.

it will be well worth your while to learn how to code for PICs anyway; this might be a challenging project to start out with (whereas most people start with some simple "hello world" type programs, flashing some LED's, etc)

it's a good idea to learn how to program PICs in assembly language, even if you don't use it in the end, because it forces you to learn how the hardware is actually set up in the PIC; after you know that, it makes programming in high-level languages much easier.
Personally I program in C using the (free) CC5X compiler, program PICs using ICPROG with a JDM serial port programmer, and have recently started using the BLoader/Screamer bootloader setup detailed at sparkfun.com, as it makes working on a program a LOT easier on PICs such as the 16F877 (don't need to keep plugging/unplugging the in-circuit programming cable)
 
Zanna said:
hi..i'm actually very new to this microcontroller stuff...i'm currently doing a project on microcontroller-based gas detector..i found the source code for the program for thegas detector..i'm planning to program the PIC 16F877 however, the code is for the MC68HC908QT1 microcontroller..can the same source code be used?..or is there major difference in the code between these two microcontroller?

One of my 'famous' analogies!.

Think of them as two different nationalities - the Motorola speaks Chinese, and the PIC speaks French - then to make things even worse, the Motorola is a Chinese fish, and the PIC a French spider.

So even if you translate the language, it still wouldn't make a great deal of sense to the other.

It's certainly possible to write PIC code to do the same job as the Motorola code - but it may well be easier to write it from scratch rather than try and translate it.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top