1. Making use of MPLAB IDE, write firmware code to switch all LED’s connected to port pins RD0-RD7 continuously on for one second and then off for one second. 2. First use a flowchart to determine the program structure and then generate your commented firmware source code.
1:
#include <htc.h>
#define _XTAL_FREQ 8000000
void main()
{
TRISD0 = 0;
TRISD1 = 0;
TRISD2 = 0;
TRISD3 = 0;
TRISD4 = 0;
TRISD5 = 0;
TRISD6 = 0;
TRISD7 = 0;
RD0 = 0; RD1 = 0; RD2 = 0; RD3 = 0; RD4 = 0; RD5 = 0; RD6 = 0; RD7 = 0; while(1) { RD0 = 1; RD1 = 1; RD2 = 1; RD3 = 1; RD4 = 1; RD5 = 1; RD6 = 1; RD7 = 1; __delay_ms(1000); RD0 = 0; RD1 = 0; RD2 = 0; RD3 = 0; RD4 = 0; RD5 = 0; RD6 = 0; RD7 = 0; __delay_ms(1000); } }
Get Answers For Free
Most questions answered within 1 hours.