5
5
* @author Generated Code
6
6
* @date 2025
7
7
* @version 1 . 0
8
- *
8
+ *
9
9
* @brief Main features:
10
10
* - LED blinking on PORTC RC2 every 500ms
11
11
* - Uses Timer0 with prescaler 1 : 256 for timing
12
12
* - External 4MHz crystal oscillator
13
13
* - Port configuration with detailed documentation
14
- *
14
+ *
15
15
* @note Hardware requirements:
16
16
* - PIC16F876A microcontroller
17
17
* - 4MHz crystal with 22pF capacitors
18
18
* - LED with series resistor on RC2
19
19
* - 5V power supply
20
- *
20
+ *
21
21
* @warning Ensure proper crystal connections for reliable operation
22
22
* /
23
23
@@ -88,7 +88,7 @@ PSECT code,class=CODE,delta=2
88
88
MAIN:
89
89
; Port configuration
90
90
BANKSEL TRISC
91
-
91
+
92
92
/ **
93
93
* @brief Port C configuration
94
94
* @details Must account for LEDs and system signals
97
97
* /
98
98
MOVLW 0b00100000 ; RC5 input, others output
99
99
MOVWF TRISC
100
-
100
+
101
101
/ **
102
102
* @brief Port A configuration
103
103
* @details Must account for LEDs , push buttons and MONO signal
@@ -107,7 +107,7 @@ MAIN:
107
107
* /
108
108
MOVLW 0b00010110 ; RA1, RA2, RA4 inputs, others output
109
109
MOVWF TRISA
110
-
110
+
111
111
/ **
112
112
* @brief Port B configuration
113
113
* @details Configuration according to system needs
@@ -116,7 +116,7 @@ MAIN:
116
116
* /
117
117
MOVLW 0b00000000 ; All PORTB outputs
118
118
MOVWF TRISB
119
-
119
+
120
120
/ **
121
121
* @brief Analog - to - digital converter configuration
122
122
* @details Configure pins as digital or analog inputs
@@ -126,7 +126,7 @@ MAIN:
126
126
* /
127
127
MOVLW 0b00000110 ; Disable ADC, all digital
128
128
MOVWF ADCON1
129
-
129
+
130
130
/ **
131
131
* @brief Timer0 configuration
132
132
* @details Configure Timer0 for timing delays
@@ -141,15 +141,15 @@ MAIN:
141
141
* /
142
142
MOVLW 0b10000111 ; Prescaler 1:256
143
143
MOVWF OPTION_REG
144
-
144
+
145
145
/ **
146
146
* @brief Port initialization
147
147
* @details Initialize all ports to known state
148
148
* @note Clear all output latches
149
149
* /
150
150
; Switch to bank 0
151
151
BANKSEL PORTC
152
-
152
+
153
153
; Clear all ports
154
154
CLRF PORTC
155
155
CLRF PORTA
@@ -165,11 +165,11 @@ MAIN_LOOP:
165
165
; Turn ON LED4 (RC2)
166
166
BSF PORTC , LED4 ; Using LED4 constant (bit 2)
167
167
CALL DELAY_500MS
168
-
168
+
169
169
; Turn OFF LED4 (RC2)
170
170
BCF PORTC , LED4 ; Using LED4 constant (bit 2)
171
171
CALL DELAY_500MS
172
-
172
+
173
173
GOTO MAIN_LOOP
174
174
175
175
/ **
@@ -184,7 +184,7 @@ MAIN_LOOP:
184
184
DELAY_500MS:
185
185
MOVLW 8 ; 8 overflows for ~500ms
186
186
MOVWF OVERFLOW_COUNT
187
-
187
+
188
188
/ **
189
189
* @brief Timer0 overflow counting loop
190
190
* @details Wait for specified number of Timer0 overflows
@@ -205,10 +205,10 @@ TIMER_LOOP:
205
205
WAIT_OVERFLOW:
206
206
BTFSS INTCON , 2 ; Check TMR0IF flag
207
207
GOTO WAIT_OVERFLOW
208
-
208
+
209
209
DECFSZ OVERFLOW_COUNT , F
210
210
GOTO TIMER_LOOP
211
-
211
+
212
212
RETURN
213
213
214
214
/ **
0 commit comments