Hello,
Once again I find myself in great difficulty in the System Architecture class. I am supposed to create a stopwatch timer as can be seen in the attached picture. Thing is, I do not understand how everything works. Here's the code I have so far (it's not mine but I have to complete it):
Okay, so apparently *portd decides of the panel on which output will be displayed. I have tried giving it values such as 0xfe, 0xfd, 0xfc, 0xfb, 0xfa. 0xfc and 0xfc give me weird values (2 panels containing the second counter at the same time).
Point is, I do not understand most of this and it is not very well explained. What does the code in hexadecimal signify? Do I need other "display" functions (like affiche_7seg) for displaying minutes for example? Thank you in advance for your help.
PS: If you don't understand what I'm talking about, it's because I am very confused with this. It's my hardest class and it is not at all well explained.
Once again I find myself in great difficulty in the System Architecture class. I am supposed to create a stopwatch timer as can be seen in the attached picture. Thing is, I do not understand how everything works. Here's the code I have so far (it's not mine but I have to complete it):
Code:
#include "iq.h"
#include "it.h"
#define byte unsigned char
/* variables globale */
byte *trisb = 0xf93 ;
byte *portb = 0xf81 ;
byte *trisd = 0xf95 ;
byte *portd = 0xf83 ;
byte *trisc = 0xf94;
byte *portc = 0xf82;
int i=0;
int nb=0;
int second = 0;
int minute = 0;
// function prototypes
void affiche_7seg(byte);
// function implementations
void affiche_7seg(byte val)
{
byte
tab_7seg[]={0b00111111,0b00000110,0b01011011,0b01001111,
0b01100110,0b01101101,0b01111101,0b00000111,0b01111111,
0b01101111};
*portb=tab_7seg[val];
}
void it_int0()
{}
void it_int1()
{}
/* interruption timer */
void it_tmr0()
{
i++;
affiche_7seg(second % 10);
affiche_7seg(minute % 10);
if ((i % 10) == 0) second ++;
if ((second % 10) == minute++);
}
// main function
void main(void)
{
*trisc = 0xff;
*trisd = 0 ;
*trisb = 0;
*portb = 0;
*portd = 0xfe; // if this is d, affiche_7seg will show the number on the next to last lcd panel
init_it_tmr0();
while(1)
{
}
}
Point is, I do not understand most of this and it is not very well explained. What does the code in hexadecimal signify? Do I need other "display" functions (like affiche_7seg) for displaying minutes for example? Thank you in advance for your help.
PS: If you don't understand what I'm talking about, it's because I am very confused with this. It's my hardest class and it is not at all well explained.
Attachments
-
109.2 KB Views: 25