Button Function Issues

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
btglarry
Posts: 15
Joined: 29 May 2011 01:41

Button Function Issues

#1 Post by btglarry » 07 Jul 2017 05:20

I am testing an application on an EasyPIC6 board and am having issue with the button function. The syntax is:

function Button(var port : byte; pin, time, active_state : byte) : byte;

Using Port A the function works perfectly when testing bits 0 and 1. However when I set the pin value to be anything greater than 1 the following code fails to work correctly.

This does not work. "SETUP MODE" is displayed when any bit on port a is high.

Code: Select all

      if ( Button( PORTA, 2, 1, 1 ) = 255 ) then
        Glcd_Write_Text( 'SETUP MODE ', 68, 7, 0 )
        else
        Glcd_Write_Text( '           ', 68, 7, 0 );
This works as it should. When only RA0 is high message is displayed.

Code: Select all

      if ( Button( PORTA, 0, 1, 1 ) = 255 ) then
        Glcd_Write_Text( 'SETUP MODE ', 68, 7, 0 )
        else
        Glcd_Write_Text( '          ', 68, 7, 0 ); 
and this works:

Code: Select all

      if ( Button( PORTA, 1, 1, 1 ) = 255 ) then
        Glcd_Write_Text( 'SETUP MODE ', 68, 7, 0 )
        else
        Glcd_Write_Text( '          ', 68, 7, 0 );
Why is this happening and what would be a work around?

chimimic
Posts: 178
Joined: 29 Sep 2007 14:35
Location: France
Contact:

Re: Button Function Issues

#2 Post by chimimic » 07 Jul 2017 14:56

PIC used ?
What about TRIS, ADC, ... main config ?
More info (and full code) will be welcome to help you...

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Button Function Issues

#3 Post by dusan.poluga » 07 Jul 2017 16:27

Hi,

Please give us more information.
If you can attach your project in a zip archive.

Best Regards,
Dusan Poluga.

btglarry
Posts: 15
Joined: 29 May 2011 01:41

Re: Button Function Issues

#4 Post by btglarry » 07 Jul 2017 16:36

PIC 16F887

Code: Select all

  ANSEL  := 0;                                      // Configure AN pins as digital I/O
  ANSELH := 0;

  Glcd_Init();                                      // Initialize GLCD

  Glcd_Fill( 0xFF );                                // Clear GLCD
  
  //Setup nav keys
  TRISA := %11111111;   //Set PORTA bits as input
I can attached the entire project if needed but it is pretty lengthy.

One thing I failed to mention is when the bit is set to 2 or greater and any input is high the message indicates "SETUP MODE".

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Button Function Issues

#5 Post by dusan.poluga » 10 Jul 2017 17:31

Hi,

Here is the button example that you have mentioned not working in your first post.
Test the example and tell me if it is working for you.
It is tested and working on our development board with pic16f887.

Best Regards,
Attachments
Button.zip
(10.52 KiB) Downloaded 106 times
Dusan Poluga.

btglarry
Posts: 15
Joined: 29 May 2011 01:41

Re: Button Function Issues

#6 Post by btglarry » 11 Jul 2017 20:16

Pressing any button on port A changes port C.

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Button Function Issues

#7 Post by dusan.poluga » 12 Jul 2017 10:49

Hi,

I do not know how this can happen.
Can you send me a picture of your hardware ?
I have tested this now and it is working properly on my board.

Best Regards,
Dusan Poluga.

btglarry
Posts: 15
Joined: 29 May 2011 01:41

Re: Button Function Issues

#8 Post by btglarry » 12 Jul 2017 14:21

See attached.

To confirm, only when the specified input on Port A goes high then low, not any input on port a, should PORT C change state. Correct?

I have used this EasyPIC6 board for quite some time and yesterday ordered the EasyPIC Pro 7.
Attachments
EasyPIC6[1].jpg
EasyPIC6[1].jpg (5.12 MiB) Viewed 4025 times

btglarry
Posts: 15
Joined: 29 May 2011 01:41

Re: Button Function Issues

#9 Post by btglarry » 12 Jul 2017 23:29

Problem resolved.

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Button Function Issues

#10 Post by dusan.poluga » 14 Jul 2017 17:23

Hi,

I am glad it was solved.

Best Regards,
Dusan Poluga.

Post Reply

Return to “mikroPascal PRO for PIC General”