-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRDA5807FP_PIC10F200.lst
More file actions
731 lines (683 loc) · 44.9 KB
/
RDA5807FP_PIC10F200.lst
File metadata and controls
731 lines (683 loc) · 44.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;======================================================================
00002 ; TITLE PIC10F2xx+PIC12F5xx+I2S+RDA5807FP+IR
00003 ; SUBTITLE PIC10F200,F202,F204,F206,F220,F222,12F508,12F509 & 12F510
00004 ; CONTENTS: RDA5807FP + I²C + I²S + NEC IR REMOTE Control
00005 ; CONTENTS: No EEPROM. Fixed starting channel and volume at startup
00006 ; EDITOR: @mit41301
00007 ; UPDATED: 11/09/2025
00008 ;======================================================================
00009
00010 ifdef __10F200
00011 include "p10F200.inc"
00001 LIST
00002
00003 ;==========================================================================
00004 ; MPASM PIC10F200 processor include
00005 ;
00006 ; (c) Copyright 1999-2013 Microchip Technology, All rights reserved
00007 ;==========================================================================
00008
00151 LIST
00012 list p=10F200
00000010 00013 RAM EQU H'0010'
0000001F 00014 MAXRAM EQU H'001F'
00000001 00015 SCL EQU GP1 ;SCL pin of the I2C Bus
00000002 00016 SDA EQU GP2 ;SDA pin of the I2C Bus
00000003 00017 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
0100 000F 0002 0000 00018 __idlocs H'F200' ;H'100'
0000
0FFF 0FEB 00019 __CONFIG _IntRC_OSC & _WDT_OFF & _CP_OFF & _MCLRE_OFF
00020 endif
00021 ;======================================================================
00022 ifdef __10F202
00023 include "p10F202.inc"
00024 list p=10F202
00025 RAM EQU h'0008'
00026 MAXRAM EQU H'001F'
00027 SCL EQU GP1 ;SCL pin of the I2C Bus
00028 SDA EQU GP2 ;SDA pin of the I2C Bus
00029 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00030 __idlocs H'F202' ;H'200'
00031 __CONFIG _IntRC_OSC & _WDT_OFF & _CP_OFF & _MCLRE_OFF
00032 endif
00033 ;======================================================================
00034 ifdef __10F204
00035 include "p10F204.inc"
00036 list p=10F204
00037 RAM EQU H'0010'
00038 MAXRAM EQU H'001F'
00039 SCL EQU GP1 ;SCL pin of the I2C Bus
00040 SDA EQU GP2 ;SDA pin of the I2C Bus
00041 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00042 __idlocs H'F204' ;H'100'
00043 __CONFIG _IntRC_OSC & _WDT_OFF & _CP_OFF & _MCLRE_OFF
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00044 endif
00045 ;======================================================================
00046 ifdef __10F206
00047 include "p10F206.inc"
00048 list p=10F206
00049 RAM EQU h'0008'
00050 MAXRAM EQU H'001F'
00051 SCL EQU GP1 ;SCL pin of the I2C Bus
00052 SDA EQU GP2 ;SDA pin of the I2C Bus
00053 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00054 __idlocs H'F206'
00055 __CONFIG _IntRC_OSC & _WDT_OFF & _CP_OFF & _MCLRE_OFF
00056 endif
00057 ;======================================================================
00058 ifdef __10F220
00059 include "p10F220.inc"
00060 list p=10F220
00061 RAM EQU H'0010'
00062 MAXRAM EQU H'001F'
00063 SCL EQU GP1 ;SCL pin of the I2C Bus
00064 SDA EQU GP2 ;SDA pin of the I2C Bus
00065 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00066 __idlocs H'F220'
00067 __CONFIG _IOSCFS_4MHZ & _WDT_OFF & _CP_OFF & _MCLRE_OFF
00068 endif
00069 ;======================================================================
00070 ifdef __10F222
00071 include "p10F222.inc"
00072 list p=10F222
00073 RAM EQU h'0009'
00074 MAXRAM EQU H'001F'
00075 SCL EQU GP1 ;SCL pin of the I2C Bus
00076 SDA EQU GP2 ;SDA pin of the I2C Bus
00077 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00078 __idlocs H'F222'
00079 __CONFIG _IOSCFS_4MHZ & _WDT_OFF & _CP_OFF & _MCLRE_OFF
00080 endif
00081 ;======================================================================
00082 ifdef __12F508
00083 include "p12F508.inc"
00084 list p=12F508
00085 RAM EQU h'0007'
00086 MAXRAM EQU H'001F'
00087 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00088 SCL EQU GP4 ;SCL pin of the I²C Bus
00089 SDA EQU GP5 ;SDA pin of the I²C Bus
00090 __idlocs H'F508'
00091 __CONFIG _IntRC_OSC & _WDT_OFF & _CP_OFF & _MCLRE_OFF
00092 endif
00093 ;======================================================================
00094 ifdef __12F509
00095 include "p12F509.inc"
00096 list p=12F509
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00097 RAM EQU H'0007'
00098 MAXRAM EQU H'003F'
00099 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00100 SCL EQU GP4 ;SCL pin of the I²C Bus
00101 SDA EQU GP5 ;SDA pin of the I²C Bus
00102 __idlocs H'F509' ;H'200'
00103 __CONFIG _IntRC_OSC & _WDT_OFF & _CP_OFF & _MCLRE_OFF
00104 endif
00105 ;======================================================================
00106 ifdef __12F510
00107 include "p12F510.inc"
00108 list p=12F510
00109 RAM EQU H'000A'
00110 MAXRAM EQU H'003F'
00111 IRx EQU GP3 ;INPUT ONLY PIN(IR Rx 38kHz)
00112 SCL EQU GP4 ;SCL pin of the I²C Bus
00113 SDA EQU GP5 ;SDA pin of the I²C Bus
00114 __idlocs H'F510' ; 400h
00115 __CONFIG _IntRC_OSC & _WDT_OFF & _CP_OFF & _MCLRE_OFF & _IOSCFS_OFF
00116 ;MESSG /*PIC12F510 is selected as TARGET*/
00117 endif
00118
00119 errorlevel +202,+205,+207,+301,+302,+305,+306,+224
00120 ;======================================================================
00121 CBLOCK RAM
00122 ;======================================================================
00000010 00123 i ;EQU 010h ;Delay variable
00000011 00124 j ;EQU 011h ;Delay variable
00000012 00125 bit_count ;EQU 012h ;Counter of processed bits in I2C
00000013 00126 i2c_data ;EQU 013h ;Data to receive/transmit via I2C
00000014 00127 port ;EQU 014h ;Helper register to implement I2C
00000015 00128 ack ;EQU 015h ;Acknowledgment received from the device
00000016 00129 volume ;EQU 016h ;Radio volume level
00000017 00130 frequency_l ;EQU 017h ;Frequency low byte
00000018 00131 frequency_h ;EQU 018h ;Frequency high byte
00132 ;======================================================================
00000019 00133 _count ;EQU 019h ;Saved value of the timer
0000001A 00134 _byte_count ;EQU 01Ah ;Counter of processed bytes
0000001B 00135 _bit_count ;EQU 01Bh ;Counter of processed bits
0000001C 00136 _ir_data:4 ;EQU 01Ch ;First IR byte
00137 ;======================================================================
00000020 00138 RAMCHK
00139 ENDC
00140 if (RAMCHK-1) > MAXRAM
00141 error "File register usage OVERFLOW"
00142 endif
00143 ;======================================================================
00144 ;volume_init EQU 0x03 | 0x80; Initial Volume = 3 // [0..15]
00000083 00145 volume_init EQU 0x03 | 1<<7 ;0x80; Initial Volume = 3 // [0..15]
00146
00000397 00147 freq EQU d'919' ; 91.9 MHz
00148 ;freq EQU d'943' ; 94.3 MHz
00149 ;freq EQU d'1040' ; 104.0 MHz
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00150 ;freqB EQU (freq - d'870') ; BAND = 0 : 87~108 MHz (US/Europe)
00000031 00151 freqB EQU (freq - 366) ; BAND = 0 : 87~108 MHz (US/Europe)
0000000C 00152 freqH EQU (freqB >> 2) ; Frequency = Channel Spacing(kHz) x CHAN + 87.0 MHz
00000040 00153 freqL EQU ((freqB&3) << 6) ; Shift channel selection for matching register 0x03
00154
0000 00155 ORG H'0000'
00156
0000 0EFE 00157 AndlW ~1
0001 0025 00158 MovWF OSCCAL
00159 ifdef __10F204
00160 BCF CMCON0,CMPON
00161 endif
00162
00163 ifdef __10F206
00164 BCF CMCON0,CMPON ;Disable Digital Comparator function
00165 endif
00166 ifdef __10F220
00167 BCF ADCON0,ADON
00168 endif
00169 ifdef __10F222
00170 BCF ADCON0,ADON ;Disable Analog to Digital function
00171 endif
00172 ifdef __12F510
00173 BCF CM1CON0,C1ON ;Disable Digital Comparator function
00174 BCF ADCON0,ADON ;Disable Analog to Digital function
00175 endif
00176
0002 00177 INIT:
0002 0C97 00178 MOVLW ~((1<<T0CS)|(1<<NOT_GPPU)|(1<<PSA))
0003 0002 00179 OPTION ;Enable GPIO2 and pull-ups
00180
0004 0C3F 00181 MOVLW 0x3F ;changed from 0x0F for 12F5xx into 'port' register
0005 0034 00182 MOVWF port ;It's used to switch SDA/SCL pins direction
0006 0006 00183 TRIS GPIO ;Set all pins as inputs
00184
0007 0CFF 00185 MOVLW 0xFF ;Perform 200 ms delay
0008 0995 00186 CALL DELAY ;to let the power stabilize
0009 0CFF 00187 MOVLW 0xFF ;Perform 400 ms delay
000A 0995 00188 CALL DELAY ;to let the power stabilize
00189
000B 0066 00190 CLRF GPIO ;Clear GPIO to set all pins to 0
00191
00192 ;DEFAULT STARTING: ;Default starting point after init
000C 0C83 00193 movlw volume_init ;0x83
000D 0C16 00194 movlw volume
000E 0C40 00195 movlw freqL ;91.90 MHz
000F 0037 00196 movwf frequency_l
0010 0C0C 00197 movlw freqH ;91.90 MHz
0011 0038 00198 movwf frequency_h
00199
0012 0CC0 00200 MOVLW 0xC0 ;Implement AND operation between 0xC0
0013 0177 00201 ANDWF frequency_l, F ;and 'frequency_l' to clear its last 6 bits
0014 0597 00202 BSF frequency_l, 4 ;Set bit 4 (Tune) to adjust the frequency
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00203 ;START_RADIO: ;Start FM radio
0015 0965 00204 CALL I2C_START ;Issue I2C Start condition
0016 0C20 00205 MOVLW 0x20 ;Radio chip address for sequential writing is 0x20
0017 096C 00206 CALL I2C_WRITE_BYTE ;Write the radio address via i2C
0018 0CD0 00207 MOVLW 0xD0 ;Write high byte into radio register 0x02/ BASS BOOST EN
0019 096C 00208 CALL I2C_WRITE_BYTE
001A 0C01 00209 MOVLW 0x01 ;Write low byte into radio register 0x02
001B 096C 00210 CALL I2C_WRITE_BYTE
001C 0218 00211 MOVF frequency_h, W ;Write high byte into radio register 0x03
001D 096C 00212 CALL I2C_WRITE_BYTE
001E 0217 00213 MOVF frequency_l, W ;Write low byte into radio register 0x03
001F 096C 00214 CALL I2C_WRITE_BYTE
00215 ;======================================================================
00216 ; IV
00217 ;======================================================================
0020 0C02 00218 MOVLW b'00000010' ;LOAD W Reg with 0x04 Register High byte
0021 096C 00219 CALL I2C_WRITE_BYTE ;Write high byte into radio register 0x04
0022 0C40 00220 MOVLW b'01000000' ;LOAD W Reg with 0x04 Register Low byte
0023 096C 00221 CALL I2C_WRITE_BYTE ;Write high byte into radio register 0x04
00222 ;======================================================================
00223 ; V
00224 ;======================================================================
0024 0C00 00225 MOVLW b'00000000' ;Write high byte into radio register 0x05
0025 096C 00226 CALL I2C_WRITE_BYTE
0026 0C00 00227 MOVLW b'00000000' ;Write low byte into radio register 0x05
0027 096C 00228 CALL I2C_WRITE_BYTE
00229 ;======================================================================
00230 ; VI
00231 ;======================================================================
0028 0C02 00232 MOVLW b'00000010' ;Write high byte into radio register 0x06
0029 096C 00233 CALL I2C_WRITE_BYTE
002A 0C70 00234 MOVLW b'01110000' ;Write low byte into radio register 0x06
002B 096C 00235 CALL I2C_WRITE_BYTE
00236 ;======================================================================
002C 0968 00237 CALL I2C_STOP ;Issue I2C Stop condition
00238 ;======================================================================
002D 0C0F 00239 MOVLW 0x0F ;Implement AND operation between 0xC0
002E 0176 00240 ANDWF volume, F ;and 'volume' to clear its higher 4 bits
002F 05F6 00241 BSF volume, 7 ;Set bit 7 to select correct LNA input
0030 0A38 00242 GOTO SET_VOLUME ;And go to the 'SET_VOLUME' label
00243
0031 00244 LOOP:
00245
0031 00246 INCREASE_VOLUME: ;Otherwise start 'INCREASE_VOLUME'
0031 02B6 00247 INCF volume, F ;Increment the 'volume' register
0032 0696 00248 BTFSC volume, 4 ;If bit 4 becomes set (volume = 0b10010000)
0033 00F6 00249 DECF volume, F ;then decrement the 'volume' to get 0b10001111
0034 0A38 00250 GOTO SET_VOLUME ;and go to the 'SET_VOLUME' label
00251
0035 00252 DECREASE_VOLUME: ;Decrease the volume here
0035 00F6 00253 DECF volume, F ;Decrement the 'volume' register
0036 07F6 00254 BTFSS volume, 7 ;If bit 7 becomes 0 (volume = 0b01111111)
0037 02B6 00255 INCF volume, F ;then increment the 'volume' to get 0b10000000
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 6
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00256
0038 00257 SET_VOLUME: ;Set the radio volume
0038 0965 00258 CALL I2C_START ;Issue I2C start condition
0039 0C22 00259 MOVLW 0x22 ;Radio chip address for random writing is 0x22
003A 096C 00260 CALL I2C_WRITE_BYTE ;Write the radio address via I2C
003B 0C05 00261 MOVLW 0x05 ;Set the register number to write to (0x05)
003C 096C 00262 CALL I2C_WRITE_BYTE ;And write it via I2C
003D 0C88 00263 MOVLW 0x88 ;Set the high byte of 0x05 register (default value)
003E 096C 00264 CALL I2C_WRITE_BYTE ;And write it via i2C
003F 0216 00265 MOVF volume, W ;Set the 'volume' as low byte of 0x05 register
0040 096C 00266 CALL I2C_WRITE_BYTE ;And write it via I2C
0041 0968 00267 CALL I2C_STOP ;Issue Stop condition
0042 0A9C 00268 GOTO _LOOP ;And return to the 'LOOP' label
00269
00270 ;CHANNEL_SEEK: ;CHANNEL_SEEK up | down
0043 00271 CH_UP:
0043 0965 00272 CALL I2C_START ;Issue I2C Start condition
0044 0C20 00273 MOVLW 0x20 ;Radio chip address for sequential writing is 0x20
0045 096C 00274 CALL I2C_WRITE_BYTE ;Write the radio address via I2C
0046 0CC3 00275 MOVLW 0xC3 ;Otherwise set 0xC3 as high byte of 0x02 register
0047 096C 00276 CALL I2C_WRITE_BYTE ;And write it via I2C
0048 0C01 00277 MOVLW 0x01 ;Set 0x01 as low byte of 0x02 register
0049 096C 00278 CALL I2C_WRITE_BYTE ;And write it via I2C
004A 0968 00279 CALL I2C_STOP ;Issue I2C Stop condition
004B 0A9C 00280 GOTO _LOOP ;And return to the '_LOOP' labe;
00281
004C 00282 SEEK_DOWN: ;Seek the station down
00283
004C 0965 00284 CALL I2C_START ;ADDEDIssue I2C Start condition
004D 0C20 00285 MOVLW 0x20 ;ADDEDRadio chip address for sequential writing is 0x20
004E 096C 00286 CALL I2C_WRITE_BYTE ;ADDEDWrite the radio address via I2C
004F 0CC1 00287 MOVLW 0xC1 ;Set 0xC1 as high byte of 0x02 register
0050 096C 00288 CALL I2C_WRITE_BYTE ;Ending of previous transaction
0051 0C01 00289 MOVLW 0x01 ;Set 0x01 as low byte of 0x02 register
0052 096C 00290 CALL I2C_WRITE_BYTE ;And write it via I2C
0053 0968 00291 CALL I2C_STOP ;Issue I2C Stop condition
0054 0A9C 00292 GOTO _LOOP ;And return to the '_LOOP' labe;
00293 ;-------------Helper subroutines---------------------------------------------
0055 00294 SDA_HIGH: ;Set SDA pin high
0055 0554 00295 BSF port, SDA ;Set 'sda' bit in the 'port' to make it input
0056 0214 00296 MOVF port, W ;Copy 'port' into W register
0057 0006 00297 TRIS GPIO ;And set it as TRISGPIO value
0058 0800 00298 RETLW 0
00299
0059 00300 SDA_LOW: ;Set SDA pin low
0059 0454 00301 BCF port, SDA ;Reset 'sda' bit in the 'port' to make it output
005A 0214 00302 MOVF port, W ;Copy 'port' into W register
005B 0006 00303 TRIS GPIO ;And set it as TRISGPIO value
005C 0800 00304 RETLW 0
00305
005D 00306 SCL_HIGH: ;Set SCL pin high
005D 0534 00307 BSF port, SCL ;Set 'scl' bit in the 'port' to make it input
005E 0214 00308 MOVF port, W ;Copy 'port' into W register
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 7
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
005F 0006 00309 TRIS GPIO ;And set it as TRISGPIO value
0060 0800 00310 RETLW 0
00311
0061 00312 SCL_LOW: ;Set SCL pin low
0061 0434 00313 BCF port, SCL ;Reset 'scl' bit in the 'port' to make it output
0062 0214 00314 MOVF port, W ;Copy 'port' into W register
0063 0006 00315 TRIS GPIO ;And set it as TRISGPIO value
0064 0800 00316 RETLW 0
00317 ;-------------I2C start condition--------------
0065 00318 I2C_START:
0065 095D 00319 CALL SCL_HIGH ;Set SCL high
0066 0959 00320 CALL SDA_LOW ;Then set SDA low
0067 0800 00321 RETLW 0
00322 ;-------------I2C stop condition---------------
0068 00323 I2C_STOP:
0068 0959 00324 CALL SDA_LOW ;Set SDA low
0069 095D 00325 CALL SCL_HIGH ;Set SCL high
006A 0955 00326 CALL SDA_HIGH ;Then set SDA highs and release the bus
006B 0800 00327 RETLW 0
00328 ;------------I2C write byte--------------------
006C 00329 I2C_WRITE_BYTE:
006C 0033 00330 MOVWF i2c_data ;Load 'i2c_data' from W register
006D 0C08 00331 MOVLW 8 ;Load value 8 into 'bit_count'
006E 0032 00332 MOVWF bit_count ;to indicate we're going to send 8 bits
006F 00333 I2C_WRITE_BIT: ;Write single bit to I2C
006F 0961 00334 CALL SCL_LOW ;Set SCL low, now we can change SDA
0070 07F3 00335 BTFSS i2c_data, 7 ;Check the MSB of 'i2c_data'
0071 0A74 00336 GOTO I2C_WRITE_0 ;If it's 0 then go to the 'I2C_WRITE_0' label
0072 00337 I2C_WRITE_1: ;Else continue with 'I2C_WRITE_1'
0072 0955 00338 CALL SDA_HIGH ;Set SDA high
0073 0A75 00339 GOTO I2C_SHIFT ;And go to the 'I2C_SHIFT' label
0074 00340 I2C_WRITE_0:
0074 0959 00341 CALL SDA_LOW ;Set SDA low
0075 00342 I2C_SHIFT:
0075 095D 00343 CALL SCL_HIGH ;Set SCL high to start the new pulse
0076 0373 00344 RLF i2c_data, F ;Shift 'i2c_data' one bit to the left
0077 02F2 00345 DECFSZ bit_count, F ;Decrement the 'bit_count' value, check if it's 0
0078 0A6F 00346 GOTO I2C_WRITE_BIT ;If not then return to the 'I2C_WRITE_BIT'
0079 00347 I2C_CHECK_ACK: ;Else check the acknowledgement bit
0079 0961 00348 CALL SCL_LOW ;Set I2C low to end the last pulse
007A 0955 00349 CALL SDA_HIGH ;Set SDA high to release the bus
007B 095D 00350 CALL SCL_HIGH ;Set I2C high to start the new pulse
007C 0206 00351 MOVF GPIO, W ;Copy the GPIO register value into the 'ack'
007D 0035 00352 MOVWF ack ;Now bit 'sda' of the 'ack' will contain ACK bit
007E 0961 00353 CALL SCL_LOW ;Set SCL low to end the acknowledgement bit
007F 0800 00354 RETLW 0
00355 ;------------I2C read byte--------------------
0080 00356 I2C_READ_BYTE:
0080 0C08 00357 MOVLW 8 ;Load value 8 into 'bit_count'
0081 0032 00358 MOVWF bit_count ;to indicate we're going to receive 8 bits
0082 0073 00359 CLRF i2c_data ;Clear the 'i2c_data' register
0083 00360 I2C_READ_BIT: ;Read single bit from the I2C
0083 0373 00361 RLF i2c_data, F ;Shift the 'i2c_data' register one bit to the left
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 8
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0084 0961 00362 CALL SCL_LOW ;Set SCL low to prepare for the new bit
0085 095D 00363 CALL SCL_HIGH ;Set SCL high to read the bit value
0086 0646 00364 BTFSC GPIO, SDA ;Check the 'sda' bit in the GPIO register
0087 0513 00365 BSF i2c_data, 0 ;if it's 1 then set the LSB of the 'i2c_data'
0088 02F2 00366 DECFSZ bit_count, F ;Decrement the 'bit_count' value, check if it's 0
0089 0A83 00367 GOTO I2C_READ_BIT ;If not, then return to the 'I2C_READ_BIT'
008A 0961 00368 CALL SCL_LOW ;Set SCL low to end the last pulse
008B 0800 00369 RETLW 0 ;Otherwise return from the subroutine
00370 ;----------I2C send ACK----------------------
008C 00371 I2C_ACK:
008C 0959 00372 CALL SDA_LOW ;Set SDA low to issue ACK condition
008D 095D 00373 CALL SCL_HIGH ;Set SCL high to start the new pulse
008E 0961 00374 CALL SCL_LOW ;Set SCL low to end the pulse
008F 0955 00375 CALL SDA_HIGH ;Set SDA high to release the bus
0090 0800 00376 RETLW 0
00377 ;----------I2C send NACK----------------------
0091 00378 I2C_NACK:
0091 0955 00379 CALL SDA_HIGH ;Set SDA low to issue NACK condition
0092 095D 00380 CALL SCL_HIGH ;Set SCL high to start the new pulse
0093 0961 00381 CALL SCL_LOW ;Set SCL low to end the pulse
0094 0800 00382 RETLW 0
00383 ;-------------Delay subroutine--------------
0095 00384 DELAY: ;Start DELAY subroutine here
0095 0030 00385 MOVWF i ;Copy the value to the register i
0096 0031 00386 MOVWF j ;Copy the value to the register j
0097 00387 DELAY_LOOP: ;Start delay loop
0097 02F0 00388 DECFSZ i, F ;Decrement i and check if it is not zero
0098 0A97 00389 GOTO DELAY_LOOP ;If not, then go to the DELAY_LOOP label
0099 02F1 00390 DECFSZ j, F ;Decrement j and check if it is not zero
009A 0A97 00391 GOTO DELAY_LOOP ;If not, then go to the DELAY_LOOP label
009B 0800 00392 RETLW 0 ;Else return from the subroutine
00393 ;======================================================================
00394 ;---IR REMOTE CONTROL 38kHz ROUTINE------------------------------------
00395 ;======================================================================
009C 00396 _LOOP: ;Main loop of the program
00397 ;---------------Wait for the preamble positive pulse-------------------
009C 0666 00398 BTFSC GPIO, IRx ;Wait while 'ir' pin goes down
009D 0A9C 00399 GOTO _LOOP ;If it's high then return to 'LOOP'
009E 0061 00400 CLRF TMR0 ;Otherwise clear the timer register
009F 0766 00401 BTFSS GPIO, IRx ;And wait while 'ir' is low
00A0 0A9F 00402 GOTO $-1
00A1 0201 00403 MOVF TMR0, W ;Copy the TMR0 value into the W register
00A2 0039 00404 MOVWF _count ;and save the value into the 'count' register
00A3 0C1E 00405 MOVLW d'30' ;Load 30 into W (256 us x 32 = 7.7 ms)
00A4 0099 00406 SUBWF _count, W ;And subtract W from 'count'
00A5 0703 00407 BTFSS STATUS, C ;If 'count' < 30 (pulse is shorter than 7.7 ms)
00A6 0A9C 00408 GOTO _LOOP ;then return to 'LOOP'
00A7 0C2D 00409 MOVLW d'45' ;Load 45 into W (256 us x 45 = 11.5 ms)
00A8 0099 00410 SUBWF _count, W ;And subtract W from 'count'
00A9 0603 00411 BTFSC STATUS, C ;If 'count' > 45 (pulse is longer than 8 ms)
00AA 0A9C 00412 GOTO _LOOP ;then return to 'LOOP'
00413 ;---------------Check the preamble negative pulse---------------------
00AB 0061 00414 CLRF TMR0 ;Otherwise clear the timer register
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 9
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00AC 0666 00415 BTFSC GPIO, IRx ;And wait while 'ir' is high
00AD 0AAC 00416 GOTO $-1
00AE 0201 00417 MOVF TMR0, W ;Copy the TMR0 value into the W register
00AF 0039 00418 MOVWF _count ;and save the value into the 'count' register
00B0 0C0D 00419 MOVLW d'13' ;Load 15 into W (256 us x 13 = 3.3 ms)
00B1 0099 00420 SUBWF _count, W ;And subtract W from 'count'
00B2 0703 00421 BTFSS STATUS, C ;If 'count' < 13 (pulse is shorter than 3.3 ms)
00B3 0A9C 00422 GOTO _LOOP ;then return to 'LOOP'
00B4 0C14 00423 MOVLW d'20' ;Load 20 into W (256 us x 20 = 5.1 ms)
00B5 0099 00424 SUBWF _count, W ;And subtract W from 'count'
00B6 0603 00425 BTFSC STATUS, C ;If 'count' > 20 (pulse is longer than 5.1 ms)
00B7 0A9C 00426 GOTO _LOOP ;then return to 'LOOP'
00427 ;---------------Receive the command bytes-----------------------------
00B8 007A 00428 CLRF _byte_count ;Clear the 'byte_count' register
00B9 0C1C 00429 MOVLW _ir_data ;Load the address of the 'ir_data' into W
00BA 0024 00430 MOVWF FSR ;and save it to the indirect pointer register
00BB 00431 _RECEIVE_BYTE:
00BB 007B 00432 CLRF _bit_count ;Clear the 'bit_count' register
00BC 0060 00433 CLRF INDF ;Clear the indirectly addressed register
00BD 00434 _RECEIVE_BIT:
00BD 0320 00435 RRF INDF, F ;Shift the INDF register to the right
00436 ;---------------Receive the positive pulse of the bit-----------------
00BE 0061 00437 CLRF TMR0 ;Otherwise clear the timer register
00BF 0766 00438 BTFSS GPIO, IRx ;And wait while 'ir' is low
00C0 0ABF 00439 GOTO $-1
00C1 0201 00440 MOVF TMR0, W ;Copy the TMR0 value into the W register
00C2 0039 00441 MOVWF _count ;and save the value into the 'count' register
00C3 0C01 00442 MOVLW 1 ;Load 1 into W (256 us x 1 = 0.26 ms)
00C4 0099 00443 SUBWF _count, W ;And subtract W from 'count'
00C5 0703 00444 BTFSS STATUS, C ;If 'count' < 1 (pulse is shorter than 0.26 ms)
00C6 0A9C 00445 GOTO _LOOP ;then return to 'LOOP'
00C7 0C03 00446 MOVLW 3 ;Load 3 into W (256 us x 3 = 0.77 ms)
00C8 0099 00447 SUBWF _count, W ;And subtract W from 'count'
00C9 0603 00448 BTFSC STATUS, C ;If 'count' > 3 (pulse is longer than 0.77 ms)
00CA 0A9C 00449 GOTO _LOOP ;then return to 'LOOP'
00450 ;---------------Receive the negative pulse of the bit-----------------
00CB 0061 00451 CLRF TMR0 ;Otherwise clear the timer register
00CC 0666 00452 BTFSC GPIO, IRx ;And wait while 'ir' is high
00CD 0ACC 00453 GOTO $-1
00CE 0201 00454 MOVF TMR0, W ;Copy the TMR0 value into the W register
00CF 0039 00455 MOVWF _count ;and save the value into the 'count' register
00D0 0C04 00456 MOVLW 4 ;Load 5 into W (256 us x 4 = 1.1 ms)
00D1 0099 00457 SUBWF _count, W ;And subtract W from 'count'
00D2 0703 00458 BTFSS STATUS, C ;If 'count' < 4 (pulse is shorter than 1.1 ms)
00D3 0AD9 00459 GOTO _NEXT_BIT ;then go to the 'NEXT_BIT' label
00D4 0C08 00460 MOVLW 8 ;Load 8 into W (256 us x 8 = 2 ms)
00D5 0099 00461 SUBWF _count, W ;And subtract W from 'count'
00D6 0603 00462 BTFSC STATUS, C ;If 'count' > 8 (pulse is longer than 2 ms)
00D7 0A9C 00463 GOTO _LOOP ;then go to the 'LOOP' label
00464
00D8 05E0 00465 BSF INDF, 7 ;Set the MSB of the INDF register
00D9 00466 _NEXT_BIT:
00D9 02BB 00467 INCF _bit_count, F ;Increment the 'bit_count' register
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 10
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00DA 077B 00468 BTFSS _bit_count, 3 ;Check if 'bit_count' becomes 8
00DB 0ABD 00469 GOTO _RECEIVE_BIT ;If it's not, then return to 'RECEIVE_BIT' label
00DC 02BA 00470 INCF _byte_count, F ;Increment the 'byte_count' register
00DD 065A 00471 BTFSC _byte_count, 2 ;Check if 'byte_count' becomes 4
00DE 0AE1 00472 GOTO _CHECK_DATA ;If it is then go to 'CHECK_DATA' label
00DF 02A4 00473 INCF FSR, F ;Increment the indirect addressing pointer
00E0 0ABB 00474 GOTO _RECEIVE_BYTE ;and go to 'RECEIVE_BYTE' label
00475
00E1 00476 _CHECK_DATA:
00E1 025D 00477 COMF _ir_data+1, W ;Negate the second received byte
00E2 019C 00478 XORWF _ir_data, W ;And implement the XOR between 1st and 2nd bytes
00E3 0743 00479 BTFSS STATUS, Z ;If the result is not 0 (bytes are not equal)
00E4 0A9C 00480 GOTO _LOOP ;Then return to the 'LOOP' label
00481
00E5 025F 00482 COMF _ir_data+3, W ;Negate the fourth received byte
00E6 019E 00483 XORWF _ir_data+2, W ;And implement the XOR between 3rd and 4th bytes
00E7 0743 00484 BTFSS STATUS, Z ;If the result is not 0 (bytes are not equal)
00E8 0A9C 00485 GOTO _LOOP ;Then return to the 'LOOP' label
00486
00E9 0C05 00487 MOVLW 0x05 ;Check the VOL- button (code 0x05)
00EA 019E 00488 XORWF _ir_data+2, W ;If command is not 0x05
00EB 0743 00489 BTFSS STATUS, Z
00EC 0AEE 00490 GOTO $+2 ;then skip the next line
00ED 0A35 00491 goto DECREASE_VOLUME
00492
00EE 0C06 00493 MOVLW 0x06 ;Check the VOL+ button (code 0x06)
00EF 019E 00494 XORWF _ir_data+2, W ;If command is not 0x06
00F0 0743 00495 BTFSS STATUS, Z
00F1 0AF3 00496 GOTO $+2 ;then skip the next line
00F2 0A31 00497 goto INCREASE_VOLUME
00498
00F3 0C02 00499 MOVLW 0x02 ;Check the << CH- button (code 0x02)
00F4 019E 00500 XORWF _ir_data+2, W ;If command is not 0x02
00F5 0743 00501 BTFSS STATUS, Z
00F6 0AF8 00502 GOTO $+2 ;then skip the next line
00F7 0A4C 00503 goto SEEK_DOWN
00504
00F8 0C03 00505 MOVLW 0x03 ;Check the W button (code 0x03)
00F9 019E 00506 XORWF _ir_data+2, W ;If command is not 0x03
00FA 0743 00507 BTFSS STATUS, Z
00FB 0AFD 00508 GOTO $+2 ;then skip the next three lines
00FC 0A43 00509 goto CH_UP ;goto channel UP routine
00510
00FD 0A9C 00511 GOTO _LOOP ;and go to the 'SET_OUTPUT' label
00512 END ;/* END of the Program */
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 11
SYMBOL TABLE
LABEL VALUE
C 00000000
CAL0 00000001
CAL1 00000002
CAL2 00000003
CAL3 00000004
CAL4 00000005
CAL5 00000006
CAL6 00000007
CH_UP 00000043
DC 00000001
DECREASE_VOLUME 00000035
DELAY 00000095
DELAY_LOOP 00000097
F 00000001
FOSC4 00000000
FSR 00000004
GP0 00000000
GP1 00000001
GP2 00000002
GP3 00000003
GPIO 00000006
GPWUF 00000007
I2C_ACK 0000008C
I2C_CHECK_ACK 00000079
I2C_NACK 00000091
I2C_READ_BIT 00000083
I2C_READ_BYTE 00000080
I2C_SHIFT 00000075
I2C_START 00000065
I2C_STOP 00000068
I2C_WRITE_0 00000074
I2C_WRITE_1 00000072
I2C_WRITE_BIT 0000006F
I2C_WRITE_BYTE 0000006C
INCREASE_VOLUME 00000031
INDF 00000000
INIT 00000002
IRx 00000003
LOOP 00000031
MAXRAM 0000001F
NOT_GPPU 00000006
NOT_GPWU 00000007
NOT_PD 00000003
NOT_TO 00000004
OSCCAL 00000005
PCL 00000002
PS0 00000000
PS1 00000001
PS2 00000002
PSA 00000003
RAM 00000010
RAMCHK 00000020
SCL 00000001
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 12
SYMBOL TABLE
LABEL VALUE
SCL_HIGH 0000005D
SCL_LOW 00000061
SDA 00000002
SDA_HIGH 00000055
SDA_LOW 00000059
SEEK_DOWN 0000004C
SET_VOLUME 00000038
STATUS 00000003
T0CS 00000005
T0SE 00000004
TMR0 00000001
TRISIO0 00000000
TRISIO1 00000001
TRISIO2 00000002
TRISIO3 00000003
W 00000000
Z 00000002
_CHECK_DATA 000000E1
_CONFIG 00000FFF
_CP_OFF 00000FFF
_CP_ON 00000FF7
_IDLOC0 00000100
_IDLOC1 00000101
_IDLOC2 00000102
_IDLOC3 00000103
_IntRC_OSC 00000FFF
_LOOP 0000009C
_MCLRE_OFF 00000FEF
_MCLRE_ON 00000FFF
_NEXT_BIT 000000D9
_OSC_IntRC 00000FFF
_RECEIVE_BIT 000000BD
_RECEIVE_BYTE 000000BB
_WDTE_OFF 00000FFB
_WDTE_ON 00000FFF
_WDT_OFF 00000FFB
_WDT_ON 00000FFF
__10F200 00000001
_bit_count 0000001B
_byte_count 0000001A
_count 00000019
_ir_data 0000001C
ack 00000015
bit_count 00000012
freq 00000397
freqB 00000031
freqH 0000000C
freqL 00000040
frequency_h 00000018
frequency_l 00000017
i 00000010
i2c_data 00000013
j 00000011
MPASM 5.51 PIC10F2XX+PIC12F5XX+I2S+RDA5807F 9-8-2025 21:14:54 PAGE 13
SYMBOL TABLE
LABEL VALUE
port 00000014
volume 00000016
volume_init 00000083
MEMORY USAGE MAP ('X' = Used, '-' = Unused)
0000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXX--
0100 : XXXX------------ ---------------- ---------------- ----------------
0FC0 : ---------------- ---------------- ---------------- ---------------X
All other memory blocks unused.
Program Memory Words Used: 254
Program Memory Words Free: 2
Errors : 0
Warnings : 0 reported, 0 suppressed
Messages : 0 reported, 0 suppressed