Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7663039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:57:16+00:00 2026-05-31T13:57:16+00:00

I am working on a simple (to get more complex later) program to read

  • 0

I am working on a simple (to get more complex later) program to read buttons from a pic24h in a microstick debugger device. I think I am initializing or reading the ports wrong, because some of the bits on the portb register, just seem to randomly come high. This code will eventually make errScreenPage = 1, even when I am not pressing the buttons. Why is this, and what can I do to make my code work?

My code is as follows:

    #include "p24HJ64GP502.h"

    int numErrors = 8;
    int moreErrorsPage = 0;
    int errScreenPage = 0;
    int maxErrScreenPage = 1;
    void setup();
    void checkBtn();

    int main(void)
    {
        setup(); //setup the pic
        wait(65535);

        while(1){
               checkBtn();
        }
        return 1;
    }
    void checkBtn(){
        if(PORTBbits.RB5 == 1 && errScreenPage != maxErrScreenPage){
            if(errScreenPage != 0 || numErrors == 0){
                errScreenPage += 1;
            }
        }
        if(PORTBbits.RB6 == 1 && errScreenPage == 0){
            errScreenPage = 1;
        }
    }
    void setup()
    {
        RPOR7 = 0x0708;
        SPI1CON1 = 0x007E;
        SPI1STAT = 0x8000;


        TRISBbits.TRISB4 = 0;
        TRISBbits.TRISB12 = 0;
        TRISBbits.TRISB13 = 0;
        LATBbits.LATB13 = 1;
        LATBbits.LATB12 = 1;
        LATBbits.LATB4 = 1;


        wait(1000);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:57:18+00:00Added an answer on May 31, 2026 at 1:57 pm

    I figured it out, i needed to pull the pin low when it was not being pulled high.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get this simple PowerShell script working, but I think something is
So i am trying to get a simple system working where i have an
I'm trying to get a simple search form working in my RoR site. I've
I am having trouble working out how to get a simple fade in fade
This should be totally simple but I can't get it working no matter what
I have this simple example I can't seems to get working : MERGE INTO
I'm sure this is really simple, but I can't seem to get it working.
I'm trying to get simple code working, unfortunately I'm a python beginner. My script
A rather simple question, but I can only find answers to more complex questions.
I'm working on simple Haskell programme that fetches a JSON string from a server,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.