Software based Modulations such as MPPM, multi-level, PPM, and PWM for VLC communication.
The program controls an AVR microcontroller to generate specific patterns of MPPM on Port D and Port B, and manages serial communication for data transmission.
-
Serial Communication Initialization (
serial_init
):- Initializes UART communication on two different UART modules (UART0 and UART1) at 19200 bps.
-
Timer Initialization (
Timer1_init
):- Configures Timer1 to generate interrupts at regular intervals for timing purposes.
-
ISR (
TIMER1_OVF_vect
):- Interrupt Service Routine for Timer1 overflow, increments a counter (
cnt
).
- Interrupt Service Routine for Timer1 overflow, increments a counter (
-
Data Transmission Functions:
transmit0
andtransmit1
: Transmit data over UART0 and UART1 respectively.Rxdata
andRxdata1
: Receive data over UART0 and UART1 respectively.
-
Bitwise Manipulation Functions:
CHECKBIT
: Macro to check specific bits in a byte.
-
Port Control Functions:
send_code_portD
andsend_code_portB
: Send specific data patterns to Port D and Port B respectively using bitwise operations.new_data_send
: Sends a new data pattern to Port D.end_break
andend_breakB
: Control functions for timing delays and port state changes.
-
Main Function (
main
):- Initializes peripherals and interrupts.
- Loops indefinitely, sending predefined data patterns to Port D, toggling an output pin on Port A, and managing timing through
end_break
.
- Utilizes Timer interrupts for precise timing operations.
- Implements UART for serial communication.
- Controls multiple ports for outputting specific bit patterns.
- Includes delay mechanisms using busy-wait loops (
cnt
variable).
- Consider optimizing delay mechanisms to reduce busy-wait time.
- Ensure synchronization and error handling in serial communication.
The program controls an AVR microcontroller to perform the following tasks:
- Initialize serial communication for UART0 and UART1.
- Initialize Timer1 for precise timing operations.
- Control output on Port C based on bit patterns.
- Receive sensor data over UART0.
-
Serial Communication Initialization (
serial_init
):- Sets baud rates for UART0 and UART1.
- Configures UART settings for 8-bit data, no parity, 1 stop bit.
-
Timer Initialization (
Timer1_init
):- Configures Timer1 in Phase Correct PWM mode with a prescaler of 8.
- Sets Timer1 to overflow at a specific cycle (
cycles
).
-
ISR (
TIMER1_OVF_vect
):- Interrupt Service Routine increments a volatile counter (
cnt
) on Timer1 overflow.
- Interrupt Service Routine increments a volatile counter (
-
Data Transmission Functions:
transmit0
andtransmit1
: Transmit data over UART0 and UART1 respectively.Rxdata
: Receive data over UART0.
-
Port Control Function (
multilevel
):- Controls Port C output based on the bit pattern of input data.
- Uses busy-wait loops (
cnt
) for timing delays.
-
Sensor Data Retrieval (
getSensorData
):- Transmits a sequence of commands over UART0 to retrieve sensor data.
- Stores received data in the array
data
.
-
Main Function (
main
):- Initializes peripherals and interrupts.
- Sets Port A, C, and D as output ports.
- Loops indefinitely, controlling Port C output based on predefined bit patterns and toggling an output pin on Port A.
- Utilizes UART for serial communication and Timer1 for timing applications.
- Implements busy-wait delay loops (
cnt
) for timing control. - Configures multiple ports (A, C, D) for output operations.
- Integrates sensor data retrieval via UART communication.
- Consider optimizing timing mechanisms to reduce reliance on busy-wait loops.
- Implement error handling and synchronization mechanisms for UART communication.
- Ensure consistent and efficient use of resources across all components.
The program controls an AVR microcontroller to perform the following tasks:
- Initialize serial communication for UART0 and UART1.
- Initialize Timer1 for precise timing operations.
- Control output on Ports C, D, and F based on bit patterns.
- Toggle an output pin on Port A.
-
Serial Communication Initialization (
serial_init
):- Sets baud rates for UART0 and UART1.
- Configures UART settings for 8-bit data, no parity, 1 stop bit.
-
Timer Initialization (
Timer1_init
):- Configures Timer1 in Phase Correct PWM mode with a prescaler of 8.
- Sets Timer1 to overflow at a specific cycle (
cycles
).
-
ISR (
TIMER1_OVF_vect
):- Interrupt Service Routine increments a volatile counter (
cnt
) on Timer1 overflow.
- Interrupt Service Routine increments a volatile counter (
-
Data Transmission Functions:
transmit0
andtransmit1
: Transmit data over UART0 and UART1 respectively.Rxdata
andRxdata1
: Receive data over UART0 and UART1 respectively.
-
Port Output Functions (
send_ppm_new_C
andsend_ppm_new_F
):- Controls output on Ports C and F based on the bit pattern of input data.
- Delays using a busy-wait loop (
cnt
) for timing control.
-
Main Function (
main
):- Initializes peripherals and interrupts.
- Sets Ports A, C, D, and F as output ports.
- Loops indefinitely, transmitting predefined bit patterns through Ports C and optionally F, toggling an output pin on Port A.
- Uses UART for serial communication and Timer1 for precise timing.
- Implements busy-wait delay loops (
cnt
) for timing control. - Configures multiple ports (A, C, D, F) for output operations.
- Demonstrates the use of ISR for Timer1 overflow.
- Consider optimizing timing mechanisms to reduce reliance on busy-wait loops.
- Ensure synchronization and error handling for UART communication.
- Validate and adjust timing settings (
cycles
) for specific application requirements.
The program controls an AVR microcontroller to perform the following tasks:
- Initialize serial communication for UART0 and UART1.
- Initialize Timer1 for precise timing operations.
- Control output on Ports A, B, D, C, and F based on bit patterns.
- Toggle an output pin on Port A.
- Read sensor data over UART0.
-
Serial Communication Initialization (
serial_init
):- Sets baud rates for UART0 and UART1.
- Configures UART settings for 8-bit data, no parity, 1 stop bit.
-
Timer Initialization (
Timer1_init
):- Configures Timer1 in Phase Correct PWM mode with a prescaler of 8.
- Sets Timer1 to overflow at a specific cycle (
cycles
).
-
ISR (
TIMER1_OVF_vect
):- Interrupt Service Routine increments a volatile counter (
cnt
) on Timer1 overflow.
- Interrupt Service Routine increments a volatile counter (
-
Data Transmission Functions:
transmit0
andtransmit1
: Transmit data over UART0 and UART1 respectively.Rxdata
: Receive data over UART0.
-
PWM Control Functions (
pwm_test
andpwm_test_B
):- Generates PWM signals on Ports A and B based on the bit pattern of input data.
- Delays using a busy-wait loop (
cnt
) for timing control.
-
End Space Function (
end_space
):- Generates an end space signal on Port A with a predefined sequence of pulses.
-
Sensor Data Acquisition (
getSensorData
):- Sends commands over UART0 to request sensor data and receives 32 bytes of data into an array (
data
).
- Sends commands over UART0 to request sensor data and receives 32 bytes of data into an array (
-
Main Function (
main
):- Initializes peripherals and interrupts.
- Sets Ports A, B, C, D, and F as output ports.
- Loops indefinitely, generating PWM signals on Port A, reading sensor data, and toggling an output pin on Port A.
- Uses UART for serial communication and Timer1 for precise timing.
- Implements busy-wait delay loops (
cnt
) for timing control in PWM functions. - Handles multiple output ports for PWM signal generation and end space signal.
- Demonstrates the use of ISR for Timer1 overflow and UART data reception.
- Optimize timing mechanisms to reduce reliance on busy-wait loops.
- Ensure synchronization and error handling for UART communication, especially in
getSensorData
. - Validate and adjust timing settings (
cycles
) and PWM patterns (pwm_test
andpwm_test_B
) based on specific application requirements.