It is currently 20 Apr 2018 04:11

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Button Function Issues
PostPosted: 07 Jul 2017 05:20 
Offline

Joined: 29 May 2011 01:41
Posts: 15
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.
      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.
      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:
      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?


Top
 Profile  
 
PostPosted: 07 Jul 2017 14:56 
Offline

Joined: 29 Sep 2007 14:35
Posts: 171
Location: France
PIC used ?
What about TRIS, ADC, ... main config ?
More info (and full code) will be welcome to help you...


Top
 Profile  
 
PostPosted: 07 Jul 2017 16:27 
Offline
mikroElektronika team
User avatar

Joined: 02 Feb 2017 14:21
Posts: 780
Hi,

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

Best Regards,

_________________
Dusan Poluga.


Top
 Profile  
 
PostPosted: 07 Jul 2017 16:36 
Offline

Joined: 29 May 2011 01:41
Posts: 15
PIC 16F887

  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".


Top
 Profile  
 
PostPosted: 10 Jul 2017 17:31 
Offline
mikroElektronika team
User avatar

Joined: 02 Feb 2017 14:21
Posts: 780
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 21 times

_________________
Dusan Poluga.
Top
 Profile  
 
PostPosted: 11 Jul 2017 20:16 
Offline

Joined: 29 May 2011 01:41
Posts: 15
Pressing any button on port A changes port C.


Top
 Profile  
 
PostPosted: 12 Jul 2017 10:49 
Offline
mikroElektronika team
User avatar

Joined: 02 Feb 2017 14:21
Posts: 780
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.


Top
 Profile  
 
PostPosted: 12 Jul 2017 14:21 
Offline

Joined: 29 May 2011 01:41
Posts: 15
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 863 times ]
Top
 Profile  
 
PostPosted: 12 Jul 2017 23:29 
Offline

Joined: 29 May 2011 01:41
Posts: 15
Problem resolved.


Top
 Profile  
 
PostPosted: 14 Jul 2017 17:23 
Offline
mikroElektronika team
User avatar

Joined: 02 Feb 2017 14:21
Posts: 780
Hi,

I am glad it was solved.

Best Regards,

_________________
Dusan Poluga.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: