Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Starting with C programming

Status
Not open for further replies.

sanjayphirke

Junior Member level 2
Joined
Feb 22, 2006
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,449
Hello everybody,

I have been using assembly language to program 8051/52 microcontrollers. I am trying to switch to C programming. I absolutely have no knowledge of C programming.

Can somebody guide me in this process. Will the same knowledge be applicable to PIC controllers as well? Also suggest the IDE / compiler to use. I will prefer free tools.

In my recent project I am using 89S52, 24C02 EEPROM, LCD controller, DS1307 RTC, FT232R USB chip to connect with PC & some interface with an existing instrument. I think it will be hard for me to use assembly in this project, so I think it will be a good start to switch in C.

Thanks
 

Embedded C


h**p://books.google.co.in/books/about/Embedded_C.html?id=RWzBQgAACAAJ

The complete introduction to embedded programming: no hardware experience required!

-- For every programmer familiar with C, C++, Java, or any other C-based language.

-- Includes extensive examples based on the 8051 microcontroller family -- the #1 platform for embedded product development.

-- CD-ROM contains all examples, plus an industry-standard compiler and simulator that lets you run, modify, and test your code on a standard Windows PC.

---------- Post added at 13:39 ---------- Previous post was at 13:37 ----------

Hello everybody,

I have been using assembly language to program 8051/52 microcontrollers. I am trying to switch to C programming. I absolutely have no knowledge of C programming.

Can somebody guide me in this process. Will the same knowledge be applicable to PIC controllers as well? Also suggest the IDE / compiler to use. I will prefer free tools.

In my recent project I am using 89S52, 24C02 EEPROM, LCD controller, DS1307 RTC, FT232R USB chip to connect with PC & some interface with an existing instrument. I think it will be hard for me to use assembly in this project, so I think it will be a good start to switch in C.

Thanks
h**p://sdcc.sourceforge.net/
SDCC is a retargettable, optimizing ANSI - C compiler that targets the Intel 8051, Maxim 80DS390, Zilog Z80, Z180, Rabbit 2000 and the Motorola 68HC08 based MCUs. Work is in progress on supporting the Microchip PIC16, PIC18 and gbz80 targets. SDCC is Free Open Source Software, distributed under GNU General Public License (GPL).
 

Thank you blooz, I got the book. I will go through it.

One more query, when I download source code for any project, there are many files (*.c & *.h) as in following example.

http://www.sixca.com/micro/mcs51/rtc_51/ds1307_51.zip



I have Keil uVision3, how can I import all these files in it to make up a project. I tried making a new project & added all the files to it. While compiling it gives following errors.

linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_DELAYUS?DELAY
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_READBYTE?DS1307
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_WRITEBYTE?DS1307
 

sanjayphirke said:
Will the same knowledge be applicable to PIC controllers as well?
One of the most important benefits o C is code portability. The only thing changes when switching from one MCU to another, is low level functions. An example of that is buttons. You will need to rewrite the code for reading the port pins, because register names and properties are different from MCU to MCU. But the part that debounces the button will be kept the same. This is one of the strongest advantages of C. On the other hand you will lose in flexibility and accurancy that assembly offered you until now.

Hope it helped,
Alexandros
 

Thank you alexx. I have started reading tutorials on C. Can you suggest a good IDE for C51 series microcontrollers.

I found a very good tutorial **broken link removed**.

Sanjay Phirke
 

sanjayphirke said:
Can you suggest a good IDE for C51 series microcontrollers.
It happened for me to work with Keil ARM tools a couple of years ago.

Average editor, pretty good compiler, excellent debugger and simulator.

As far as I know C51 enviroment had the same debugging tools more or less.

You could try the limited code demo edition out.

Keil 8051 Microcontroller Development Tools
 

Thanks alexxx. One more thing, as I stated I use C51 for my projects. Should I switch to AVR or ARM processors.

As mentioned in my first post my project is a data logger, which will capture data from an instrument, store it along with time stamp & then it will be downloaded to PC. I think 89S52 is sufficient for this project. What aspects should be considered while choosing the micro-controller family?

As far as I know, ARM is very powerful processor. In which types of projects should we consider using ARM processor?
 

sanjayphirke said:
What aspects should be considered while choosing the micro-controller family?
With a few exceptions of modernized 8-bit MCUs (AVR XMega among others just came in mind), the other 8-bit families are more or less the same. One family is better on one aspect, another family on another, etc. With 16-bit MCUs I didn't have the chance to work on yet, but I think it is better to move on to 32-bit instead. ARM processors are really powerful, they are specialized on touch screens applications, smart phones, game controllers, PDAs etc. There is no point of using an ARM processor just to read a button and drive a LED. There are cheaper solutions to achieve this goal. Recently an ARM family called Cortex-M0 came ahead as a cost effective 32-bit solution for real time applications. I didn't have the chance to play with it yet, but it's intended to compete in the 8-bit and 16-bit market.

Cortex-M0 Processor - ARM
 

I would say that the move to AVR is worth it. I would say that it's more powerful than the 89C51 micros.

If you want to go to 32-bit, ARM could be the first choice. However, you need to decide if you really need the power of a 32-bit microcontroller. One thing that stopped me from making a move to 32-bit micros (besides the fact that I don't really need them) is that they are not available in DIP packages (at least, as far as my knowledge goes). So testing on breadboard is extremely difficult and with the DIP "adapters", I can't even use it on breadboard.

I usually use the PIC/AVR and when I need more power, I use the dsPIC. The dsPIC is a good choice for me since it's plenty powerful for my needs, available in DIP package and also cheaper than PIC18 (at least for me).

Hope this helps.
Tahmid.
 

Thanks alexxx, Tahmid.

After reading your answers, I am very excited to use more powerful processors in my further projects. I will definitely ask queries about those in this forum & I am sure I will get help in this forum (especially I am interested in dsPIC as mentioned by Tahmid).

Till now, I have just started using C for AT89S52. For testing my hardware & concept of using C language I downloaded a sample project from keil web site...

Application Note 161: Interface and Simulation of an LCD Text Display

I changed some declares to match my hardware, compiled it with no errors & then programmed the controller. But there was no change in LCD status. I am using standard 16*2 character LCD.

Then in the main routine I added some code to sound buzzer, light/blink some LEDs which I had on board. That works perfectly, no display in LCD (only upper 16 characters lit, as after reset condition). I hope you people can help in this matter.


Sanjay

---------- Post added at 18:59 ---------- Previous post was at 18:52 ----------

One more question. What is the purpose of using printf command in C (for micro controllers). I know, it displays the text on screen in regular C for DOS/Windows.

This command is used in the main routine in the example program.



Code:
void main (void)  {
  unsigned char c;

Buz=0;
LED1=1;
LED2=0;
LED3=1;

  for (c = 'A'; c < 'H'; c++)  {
    putchar (c);
  }
  [B]printf [/B]("Hello \n");

  Clear_Display ();
  for (c = 0; c < 10; c++)  {
    [B]printf [/B]("This is Display Line %bd\n", c);
  }
  while (1);
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top