This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

increment and decrement of 7 segment(0-99 count) using 2 buttons

Question: Interface two seven-segment LED displays to Port C of STM32F4 MCU that mustincrement and show the rolling of two digits from 00 onwards, to a max of 99, when aswitch SW1 (PB0) is pressed. And must decrement when the user is pressing SW2(PB1).

the issues we are facing is there is increment and decrement happening but then increment is not happening after it is decrementing till 0

the other issues which are being faced are mentioned below 

1) the system is operating even when both the both the switches are off to the topmost mentioned conditional IF loop let it be increment or decrement

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//program starts from here
#include<stm32f401xe.h>
unsigned char Digit[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x6f};
void MSdelay(unsigned int );
void MSdelay(unsigned int times)
{
····unsigned int i=0,j=0;
····for(j=0;j<times;j++)
····{
········for(i=0;i<1400;i++);
····}········
}
int main(void)
{
·······unsigned int count1=0;//intialising count variable
·······RCC->AHB1ENR|=6;//initialising clock for port B and port C
················GPIOB->MODER&=~(0XF);//clearing and setting port B as input
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The conditions which are to be satisfied for us are 

1) both on nothing should be done
2) both off nothing should be done
3) xor operation it should do increment/decrement(one OFF one ON combination)
4) after 99 in increment it should halt and not go to 0
5) after 0 in decrement it should stop

the proteus desgin we are testing on is mentioned below 

proteus simulation link

0