Search the Community

Showing results for tags 'basys mx3'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • New Users Introduction
    • Announcements
  • Digilent Technical Forums
    • FPGA
    • Digilent Microcontroller Boards
    • Non-Digilent Microcontrollers
    • Add-on Boards
    • Scopes & Instruments
    • LabVIEW
    • Other
  • General Discussion
    • Project Vault
    • Learn
    • Suggestions & Feedback
    • Buy, Sell, Trade
    • Sales Questions
    • Off Topic
    • Educators
    • Technical Based Off-Topic Discussions

Calendars

  • Community Calendar

Found 1 result

  1. Good afternoon, I have the following problem with BASYS MX3: When I try using BTNL or BTNU in debug mode, they are read as 1 when they are not pressed, but only sometimes, yet regularly. This problem does not occur when I press "Make and program device Main Project" instead of "Debug main project". Other buttons are working just fine with both debug and program mode. The code I am using: /* assignment1_3.c */ #include <xc.h> #include "assignment1_3.h" int main(){ TRISA = 0x00; TRISBbits.TRISB1 = 1; // RB1 (BTNU) configured as input ANSELBbits.ANSB1 = 0; // RB1 (BTNU) disabled analog TRISBbits.TRISB0 = 1; // RB1 (BTNL) configured as input ANSELBbits.ANSB0 = 0; // RB1 (BTNL) disabled analog TRISFbits.TRISF4 = 1; // RF0 (BTNC) configured as input TRISBbits.TRISB8 = 1; // RB8 (BTNR) configured as input ANSELBbits.ANSB8 = 0; // RB8 (BTNR) disabled analog TRISAbits.TRISA15 = 1; // RA15 (BTND) configured as input LATA = 0x00; //Turn the leds off int i = 0; while(1){ if (BTNL == 1){ //going mad: BTNU, BTNL, Going well: BTND, BTNR, BTNC i++; int a = 0; for (a; a < 100000; a++){}; while (BTNL){}; for (a; a < 100000; a++){}; LATA = i%16; } } return (0); } #ifndef ASSIGNMENT1_3_H #define ASSIGNMENT1_3_H /* ------------------------------------------------------------ */ /* Configuration Bits */ /* ------------------------------------------------------------ */ // Device Config Bits in DEVCFG1: #pragma config FNOSC = FRCPLL #pragma config FSOSCEN = OFF #pragma config POSCMOD = XT #pragma config OSCIOFNC = ON #pragma config FPBDIV = DIV_2 // Device Config Bits in DEVCFG2: #pragma config FPLLIDIV = DIV_2 #pragma config FPLLMUL = MUL_20 #pragma config FPLLODIV = DIV_1 #pragma config JTAGEN = OFF #pragma config FWDTEN = OFF #pragma config DEBUG = ON // Debugger Enable/Disable /* ------------------------------------------------------------ */ /* Definitions */ /* ------------------------------------------------------------ */ #define BTNC PORTFbits.RF0 #define BTNU PORTBbits.RB1 #define BTNL PORTBbits.RB0 #define BTNR PORTBbits.RB8 #define BTND PORTAbits.RA15 #endif /* ASSIGNMENT1_3_H */ The idea of the program is to increment the counter whenever the button is pressed, which works fine in for all the buttons but BTNU and BTNL. For those two the button is read as 1 without pressing, but it is also read as 0, because while(BTNL) actually exits. The questions are: why do programming the device works just fine for all the buttons, but debugging only for some of them? Why does it happen to up and left button only? What can I do to fix it? This bug was also noticed by my teacher and one of my friends, so it does not seem to be related to a single board. I am using compiler XC32 v1.44 and MPLAB X IDE v4.00 Many thanks for your input, Michał Mikołajczyk