[HELP]Does 8051 not support pointer as good as PIC?

General discussion on mikroC PRO for 8051.
Post Reply
Author
Message
croket_2512
Posts: 41
Joined: 05 Aug 2014 03:35

[HELP]Does 8051 not support pointer as good as PIC?

#1 Post by croket_2512 » 06 Jan 2015 15:40

Hello,

I have a simple program to test pointer variable for 8051 and PIC. This variable uses to pass an IO port into a function. Here it is:

Code: Select all

void Port_LED_0(unsigned char *);
void Port_LED_1(unsigned char *);

void Port_LED_0(unsigned char *port)
{
 (*port) = 0;
}

void Port_LED_1(unsigned char *port)
{
 (*port) = 0xFF;
}

void main(void)
{
 Port_LED_0(&P2); //For PIC: Port_LED_0(&PORTB);
 Delay_ms(500);
 Port_LED_1(&P2); //For PIC: Port_LED_1(&PORTB);
 Delay_ms(500);
}
The problem is the program executes on PIC good but do not excutes on 8051. The LEDs don't blink. And when I compare the Button library of mikroC between 8051 and PIC, I see some differences between them. So, does the the architecture 8051 not support pointer as good as PIC or does the compiler have error inside it or my program is wrong?

Thank you for reading.

Best regards.

croket_2512
Posts: 41
Joined: 05 Aug 2014 03:35

Re: [HELP]Does 8051 not support pointer as good as PIC?

#2 Post by croket_2512 » 08 Jan 2015 02:05

Hi,

Can someone help me?

Best regards.

User avatar
nemanja.nikolic
Posts: 171
Joined: 01 Dec 2014 10:50

Re: [HELP]Does 8051 not support pointer as good as PIC?

#3 Post by nemanja.nikolic » 08 Jan 2015 15:10

Hello,

Configure PORTB as digital and output.
Your code does not work in mikroC PRO for PIC.
Please read about pointers in c language.

I was modify your code and now work on PIC.

Code: Select all


void Port_LED_0(unsigned char *);
void Port_LED_1(unsigned char *);

void Port_LED_0(unsigned char *port)
{
 (*port) = 0;
}

void Port_LED_1(unsigned char *port)
{
 (*port) = 0xFF;
}

void main(void)
{
 TRISB=0x00;
 
 while (1){
    Port_LED_0(&PORTB); //For PIC: Port_LED_0(&PORTB);
    Delay_ms(500);
    Port_LED_1(&PORTB); //For PIC: Port_LED_1(&PORTB);
    Delay_ms(500);
 }
 
}

Nemanja.

Best regards.

croket_2512
Posts: 41
Joined: 05 Aug 2014 03:35

Re: [HELP]Does 8051 not support pointer as good as PIC?

#4 Post by croket_2512 » 08 Jan 2015 16:56

Hi,

You misunderstand my mind. I mean the code doesn't work on 8051, it works good on PIC. I keep in my mind, we all know config IO port for PIC, so I didn't write down here.

Best regards.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [HELP]Does 8051 not support pointer as good as PIC?

#5 Post by filip » 09 Jan 2015 16:46

Hi,

You are right, something is definitely wrong, we will investigate this.

Regards,
Filip.

croket_2512
Posts: 41
Joined: 05 Aug 2014 03:35

Re: [HELP]Does 8051 not support pointer as good as PIC?

#6 Post by croket_2512 » 09 Jan 2015 17:30

Hi,

I will waiting for you. Thank you so much, all of you! :)

Best regards.

Post Reply

Return to “mikroC PRO for 8051 General”