Multisim and Ultiboard

cancel
Showing results for 
Search instead for 
Did you mean: 

8051 C in multisim

Solved!
Go to solution

Hi Folks

 

Could some one point me in the direction of any documentation on writing C for the 8051 in Multisim?

 

That is specifically C, not asm

And specifically for the multisim 8051 compiler.

 

I am new to multisim, though I have a lot of experienca with the 8051 and C I cannot figure out how to reference the MCU pins and registers.

trying to include reg51.h results in an error, and of course without it code such as "P1 = 0xA4" gives an error as the compiler does not understand "P1"

 

I have tried searching google this site and Hitech's site for these simple items with no luck, everything either uses asm  or is an unsolved/unanswered thread...

 

Many thanks

0 Kudos
Message 1 of 7
(12,016 Views)

Hi,

 

Here is the user guide. if you still can get it to work, please post your code and project file and i'll try to help you.

 

Mahmoud W

National Instruments

Message 2 of 7
(12,010 Views)

Hi Mahmoud

 

Many thanks for your hlep. However, I have already seen this document (I read it again just to be certain) but it contains NO information on using C, reg51.h (or any other c51 header) or the Hi-tech C-51 compiler, but only on using asembly and the assembler.

 

If you note in my original post I mention that I specifically wish to find information on using C, NOT ASEMBLY.

 

Agian many thanks for your help, if there is no documents available for using C, then I'll have to use asm, but I am trying to teach my students embedded C programming, not asm, so I'll end up doing most of the work myself and the students will lose the experience...

 

 

Currently main.c code consists of:

#include "keypad.h"
#include<REG51.h>

void main(void)
{
	initKeypad();
	EA = 1;
				
	while (1) {}
	
}

keypad.c is added to the project and keypad.h is correctly included in the build (according to the build output).

keypad.h also attempts to include reg51.h also, with the same error.

I have tried including <REG51.h>, <reg51.h>, "REG52.h" and "reg51.h"

 

0 Kudos
Message 3 of 7
(12,001 Views)

For anybody looking for the same thing (and I see a few in the forums):

 

Do not use reg51, as I thought initially it is Keil compiler specific. The compiler used by multisim is Hi-tech's C-51 compiler. Hi-tech's website is pretty sparse on real info in this area especially if your not using a PIC so dont bother looking there.

Instead include <htc.h>

 

htc.h is a small enough file that will, based on what type of MCU you have included, include the appropriate headers for your device.

 

for example, after a cursory reading I can see that for my generic 8051 MCU it most likely includes 8051.h, for a PIC it includes pic.h, amd so on.

 

In turn 8051.h includes the specific device header, again I am using the built in generic 8051 and in this case it doesnt seem to be so easy to see what includes are then added as all the defines seem to be device specific, but I made a guess at 805x.h

 

These includes all include each other and some, like 805x.h, warn against including them directly. 

So best just to include htc.h and leave it at that.

 

However, reading 805x.h will help with the syntax of declaring sfr's and bits etc.

The 8051 header files should all be located in: "C:\Program Files\HI-TECH Software\HC51\lite\9.60\include" if you installed multisim in the default directories.

 

The only thing I'm missing at the moment is the syntax for declaring ISR's... if somebody knew that and could let me know it would be great 🙂

 

Thanks

 

PS: also if somebody knows what "device-specific" header is used for the generic 8051 MCU would be great.

I'll prob start a thread over on Hi-Tech's forum to ask these Q's also

Message 4 of 7
(11,982 Views)
Solution
Accepted by topic author wolf99

I have not used the Hi-Tech C compiler from within Multisim but I do use it as part of MPLAB for PICs but I would think it is the same.

 

The function must be declared as type interrupt and not have any parameters, for example:  interrupt isr (void)

 

This function will be called when ANY interrupt is detected.   You will need to set up and enable the interrupts first.  If you have multiple sources, they will all call this function.

 

Look in the Hi-Tech C docs folder in the installation directory for the manual.  Mine is C:\Program Files\HI-TECH Software\PICC\9.80\docs\manual.pdf.  My manual has a section "INTERRUPT HANDLING IN C". 

Message 5 of 7
(11,966 Views)

Thanks Tom, Im just after finding that document myself also, very handy, many thanks!

0 Kudos
Message 6 of 7
(11,963 Views)

here is all problem due to the header file used in multisim it is htc.h 

for more on " c language in multisim " just check it they have complete guide

http://electronets.blogspot.com

http://electronets.blogspot.com/2012/01/how-to-use-c-language-in-multisim-for.html

0 Kudos
Message 7 of 7
(11,565 Views)