Simple Software Question

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
mstrdenz91
Posts: 8
Joined: 13 Dec 2011 14:10

Simple Software Question

#1 Post by mstrdenz91 » 13 Dec 2011 14:27

Hi, I am trying to light a LED by pushing a button on the touchscreen.
I get into a function of the buttonclick but still the LED won't go on.
I connected the pin to the gate of a FET wich will turn on at a gate voltage of around 2,6V.
(When I connect 3,3V to the gate the LED does light up.)
This is the code I use:

Code: Select all

//--------------------- User code ---------------------//
bit label;

void InitIO()
{
  //ADPCFG = 0xFFFF;
  TRISB = 0x0000;
  PORTB = 0xFFFF;
}
//----------------- End of User code ------------------//

// Event Handlers

void Button1Click() {
      PORTB = PORTB || 0x0006;  
       //PORTB.B1 = 1;
      strcpy(Label3.Caption, "Solenoid on");
      DrawLabel(&Label3);
}

void Button2Click() {
 InitIO();
}
My question: why can't I get an output voltage on the Pin(s) (I also measured it).
I must have done something wrong in the code although I believe this is standard C.
Any help will be verry much appreciated!

Yako
Posts: 32
Joined: 11 Dec 2011 23:23

Re: Simple Software Question

#2 Post by Yako » 14 Dec 2011 09:06

mstrdenz91 wrote:

Code: Select all


void Button1Click() {
      PORTB = PORTB || 0x0006;  
       //PORTB.B1 = 1;
      strcpy(Label3.Caption, "Solenoid on");
      DrawLabel(&Label3);
}

void Button2Click() {
 InitIO();
}
Hello,

What you have posted is not C code, it looks like MS Visual XXX code in part.

Kind regards,

Yako.

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Simple Software Question

#3 Post by p.erasmus » 14 Dec 2011 09:41

mstrdenz91 wrote:What you have posted is not C code, it looks like MS Visual XXX code in part.
I think it is C code,it comes from the mikroE Visual TFT software !
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

mstrdenz91
Posts: 8
Joined: 13 Dec 2011 14:10

Re: Simple Software Question

#4 Post by mstrdenz91 » 14 Dec 2011 09:57

Yes I used Visual TFT and in the _events_code.C file I put this code.
The rest of the code is just to make the screen and buttons etc.
(also I know I get into the function because label 3 DOES show "Solenoid on" on the screen).

But as far as I can see this is normal C code and I have always driven my I/O ports like this.

So I would be happy if anyone has any possible solution for this.

Thanks in advance,
Dennis

PeterA
Posts: 127
Joined: 02 Jul 2008 11:01

Re: Simple Software Question

#5 Post by PeterA » 14 Dec 2011 14:37

Hi

Depending on type of pic you are using. try to assign to LATB register instead of PORTB.

Post Reply

Return to “mikroC PRO for PIC General”