Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * Seven - segment display counter * * This program counts number 0 - 3 on the seven segment display. * The seven segment
Sevensegment display counter
This program counts number on the seven segment display.
The seven segment display is driven by a shift register which is
connected to SSI in SPI mode.
Built and tested with Keil MDKARM v and TMCDFP v
#include TMCh
void delayMsint n;
void sevenseginitvoid;
void SSIwriteunsigned char data;
int mainvoid
const static unsigned char digitPatternxBxAxFxC;
int i;
sevenseginit; initialize SSI that connects to the shift registers
while
SSIwritedigitPatterni; write digit pattern to the seven segments
SSIwrite i; select digit
if i
i ;
delayMs;
enable SSI and associated GPIO pins
void sevenseginitvoid
SYSCTLRCGCGPIO x; enable clock to GPIOB
SYSCTLRCGCGPIO x; enable clock to GPIOC
SYSCTLRCGCSSI x; enable clock to SSI
PORTB for SSI TX and SCLK
GPIOBAMSEL & ~x; turn off analog of PORTB
GPIOBAFSEL x; PORTB for alternate function
GPIOBPCTL & ~xFF; clear functions for PORTB
GPIOBPCTL x; PORTB for SSI function
GPIOBDEN x; PORTB as digital pins
PORTC for SSI slave select
GPIOCAMSEL & ~x; disable analog of PORTC
GPIOCDATA x; set PORTC idle high
GPIOCDIR x; set PORTC as output for SS
GPIOCDEN x; set PORTC as digital pin
SSICR; turn off SSI during configuration
SSICC ; use system clock
SSICPSR ; clock prescaler divide by gets MHz clock
SSICRx; clock rate div by phasepolarity mode freescale, data size
SSICR; enable SSI as master
This function enables slave select, writes one byte to SSI
wait for transmit complete and deassert slave select.
void SSIwriteunsigned char data
GPIOCDATA & ~x; assert slave select
SSIDR data; write data
while SSISR & x wait for transmit done
GPIOCDATA x; deassert slave select
delay n milliseconds MHz CPU clock
void delayMsint n
int i j;
fori ; i n; i
forj ; j ; j
do nothing for ms
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started