Question: Description: - This program uses macro functions definitions to set, clear, toggle and check a bit in position n of a given PORT. Inputs: -

Description:- This program uses macro functions definitions to set, clear, toggle and check a bit in position n of a given PORT. Inputs:- None Outputs:-8 outputs on PORTB (i.e. RB7 RB0) Instructions:-1. Create a function macro for setting, clearing, toggling and checking a particular bit of a PORT. E.g. #define setbit(port, bitn).................. #define clearbit(port, bitn)................. #define togglebit(port, bitn)................. #define checkbit(port, bitn).............. where, bitn =0,1,2......7(i.e bits 0 to 7 in a PORT).2. Inside main(), call the four macro definitions above inside a continuous loop, on PORTB, to test the operation of each marco. Insert a programmable delay, with a default value of 2000mSec, between each marco call to see if each macro operates correctly by observing the LEDs turning on/off. Ensure to clear PORTB before entering the continuous loop. Use the following sequence inside a continuous loop:-
Set PORTB Bit 0 Delay Set PORTB Bit 1 Delay Clear PORTB Bit 0 Delay Toggle PORTB Bit 1 Delay Toggle PORTB Bit 2 Delay If PORTB BIT2 is set then set PORTB Bit 3 else clear PORTB Bit 3 Delay
3. Add comments to your code (marks lost for no comments).4. Ensure all code is properly indented (i.e. marks lost for no indentation)
Description: - This program uses macro functions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!