FROM The HCS12 / 9S12 (2nd Edition) E4.19
please use C language to write the code and submit the code and pictures of the running circuit on the board.
(1) Write an instruction sequence to configure Port A and Port B for input and output,
respectively; read the value of Port A and output the value to Port B.
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
main()
{
DDRA = 0x00 /*Make PORTA as input*/
PORTA = 1; /*initialize all input with value 1*/
DDRB = 0xff; /* Make PORTB output */
PORTB = 0; /* Start with all off */
while(1)
{
PORTB = PORTA; /*Assign the values of PORT A(input PORT) to PORT B
}
}
Get Answers For Free
Most questions answered within 1 hours.