need help for the segment display: from 0 to F, such as 0,1,2,3,4,5,6,7,8,9,A,B,
ID: 2248194 • Letter: N
Question
need help for the segment display: from 0 to F, such as 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. no delay. start from #include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdbool.h>
#include<TM4C123GH6PM.h>
thank you
Unlock Port TMAC 123G PDZ must be unlockod, other Fil the GPI0 Pin Configuration Table wise the dp pin can not work Check L OUT seg. a PA2 Digital 0-GPIO PA4 Digital 0-GPIO OUT seg_c dW PC4-1 Digital le 0-GPIO-OUT PC5 || Digital 10-GPIO OUT Digital 0-GPIO PC7 DigitalPIO OUT Digital 0-GPIO Digital 0-GPIO Digital 0-GPIO Digital 0-GPIO Digital 0-GPIO Digtal 0-GPIO segif PC6 seg.9 seg.dpPD7 Convert above configurat tion into registers Fnnctionn Re Value in binary Value in Hex Go to topExplanation / Answer
#include <avr/io.h>
#include <util/delay.h>
//Ten's place connected to port a
//one's place connected to port b
uint8_t converto7seg(uint8_t number)
{
//routine to convert the number into 7 segment. Write directly to port.
switch (number)
{
case 1: return 0x06;
case 2: return 0x5b;
case 3: return 0x4f;
case 4: return 0x66;
case 5: return 0x6d;
case 6: return 0x7d;
case 7: return 0x07;
case 8: return 0x7f;
case 9: return 0x6f;
case 0: return 0x3f;
}
}
void twodigitwithoutenable (uint8_t number)
{
//routine to print the 2 digit number to 7segment
if (number>99) return;
PORTA=convert7seg(number/10); //send the ten's number to 7segment display
PORTB=convert7seg(number%10); //send the one's number to 7segment display
}
int main(void)
{
uint8_t i;
DDRA=0xFF; //set data direction to output
DDRB=0xFF;
while (1)
{
for(i=0;i<100;i++)
{
twodigitwithoutenable(i); //cycle from 00 to 99
_delay_ms(300); //to make it easier to read
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.