Initial import of goggles v2
[goggles] / disassembly / listing.disasm
CommitLineData
5fc23db2
JM
1Disassembly Listing for led_test
2Generated From:
3/home/justin/MPLABXProjects/led_test.X/dist/XC8_PIC12F1840/debug/led_test.X.debug.cof
414-Jun-2013 12:31:18
5
6--- /home/justin/MPLABXProjects/led_test.X/ws2811.c ---------------------------------------------------
71: #include <stdint.h>
82: #include <stdbool.h>
93:
104: #include "system.h"
115: #include "user.h"
126:
137: #include "ws2811.h"
148:
159: // how many LEDs are there
1610: #define LED_COUNT 8
1711:
1812: #define RGB_COUNT (LED_COUNT*3)
1913:
2014: #define SEND_ONE 0b11111000
2115: #define SEND_ZERO 0b11000000
2216:
2317: unsigned rgbdata[RGB_COUNT];
2418:
2519: volatile uint8_t rgb_sample = 0;
2620: volatile int8_t rgb_byte = 0;
2721: volatile int8_t rgb_bit = 0;
2822:
2923: #if 0
3024: /* interupt handling routine:
3125: * aka: send next bit
3226: */
3327: #pragma interrupt_level 1
3428: void ws2811_int(void)
3529: {
3630: //if (rgb_byte == 0) return;
3731:
3832: /*
3933: rgb_sample <<= 1;
4034:
4135: if ( rgb_sample & 0x80 )
4236: SSP1BUF = SEND_ONE;
4337: else
4438: SSP1BUF = SEND_ZERO;
4539: */
4640:
4741: asm("MOVLW 0xC0");
4842: asm("RLF _rgb_sample,f");
4943: //asm("BTFSC CARRY");
5044: asm("BTFSC STATUS,0");
5145: asm("MOVLW 0xF8");
5246: asm("BANKSEL (SSP1BUF)");
5347: asm("MOVWF SSP1BUF & 0x7F");
5448:
5549: asm("DECFSZ _rgb_bit,f");
5650: asm("RETURN");
5751:
5852: /* next byte */
5953:
6054: asm("MOVLW 8");
6155: asm("MOVWF _rgb_bit");
6256: asm("DECFSZ _rgb_byte");
6357: asm("BRA ws2811_loadnext");
6458:
6559: /* count is zero, were all done */
6660: asm("BANKSEL (PIE1)");
6761: //asm("BCF SSP1IE");
6862: asm("BCF PIE1 & 0x7F,3");
6963: asm("RETURN");
7064:
7165: asm("ws2811_loadnext:");
7266: if (rgb_byte)
7367: rgb_sample = rgbdata[rgb_byte-1];
7468: else
7569: PIE1bits.SSP1IE = 0;
7670:
7771: }
7872: #endif
7973:
8074: void ws2811_start(void)
8175: {
8276: rgb_byte = RGB_COUNT;
830760 3018 MOVLW 0x18
840761 00F1 MOVWF 0x71
850762 0871 MOVF 0x71, W
860763 00F8 MOVWF rgb_byte
8777: ws2811_send(); // send the first bit
880764 3180 MOVLP 0x0
890765 2000 CALL 0x0
900766 3187 MOVLP 0x7
9178: }
920767 0008 RETURN
9379:
9480: bool ws2811_running(void)
9581: {
9682: if (rgb_byte) return true;
9783: return false;
9884: }
99--- /home/justin/MPLABXProjects/led_test.X/user.c -----------------------------------------------------
1001: /******************************************************************************/
1012: /* Files to Include */
1023: /******************************************************************************/
1034:
1045: #if defined(__XC)
1056: #include <xc.h> /* XC8 General Include File */
1067: #elif defined(HI_TECH_C)
1078: #include <htc.h> /* HiTech General Include File */
1089: #endif
10910:
11011: #include <stdint.h> /* For uint8_t definition */
11112: #include <stdbool.h> /* For true/false definition */
11213:
11314: #include "user.h"
11415:
11516: /******************************************************************************/
11617: /* User Functions */
11718: /******************************************************************************/
11819:
11920: /* <Initialize variables in user.h and insert code for user algorithms.> */
12021:
12122: void InitApp(void)
12223: {
12324: /* TODO Initialize User Ports/Peripherals/Project here */
12425:
12526: /* Setup analog functionality and port direction */
12627:
12728: /* Initialize peripherals */
12829:
12930: /* Enable interrupts */
13031:
13132: // SPI MASTER mode div4 t-to-h
13233: SSP1CON1bits.SSPEN = 1; // enable MSSP
1330771 0024 MOVLB 0x4
1340772 1695 BSF TMR0, 0x5
13534: TRISAbits.TRISA0 = 0; // SDO is RA0
1360773 0021 MOVLB 0x1
1370774 100C BCF PORTA, 0x0
13835: ANSELAbits.ANSA0 = 0; // not analog
1390775 0023 MOVLB 0x3
1400776 100C BCF PORTA, 0x0
14136:
14237: // SCK (SPI Clock) is RA1
14338: // SDI (SPI In) is RA2
14439: APFCONbits.SDOSEL = 0; // use RA0 not RA4 for output
1450777 0022 MOVLB 0x2
1460778 131D BCF 0x1D, 0x6
14740:
14841: // at 8MHz Tclk 0 = 2 bits, 1 = 6 bits.
14942: // write to SSP1BUF
15043: SSP1CON1bits.SSPM = 0b0000; // SPI Master Fosc/4
1510779 30F0 MOVLW 0xF0
152077A 0024 MOVLB 0x4
153077B 0595 ANDWF TMR0, F
15444:
15545: // enable SPI interupts
15646: // PIE1bits.SSP1IE = 1; // SPI interupt enable
15747: // INTCONbits.PEIE = 1; // peripheral int enable
15848: // INTCONbits.GIE = 1; // master int enable
15949:
16050: }
161077C 0008 RETURN
16251:
16352:
164--- /home/justin/MPLABXProjects/led_test.X/system.c ---------------------------------------------------
1651: /******************************************************************************/
1662: /* Files to Include */
1673: /******************************************************************************/
1684:
1695: #if defined(__XC)
1706: #include <xc.h> /* XC8 General Include File */
1717: #elif defined(HI_TECH_C)
1728: #include <htc.h> /* HiTech General Include File */
1739: #endif
17410:
17511: #include <stdint.h> /* For uint8_t definition */
17612: #include <stdbool.h> /* For true/false definition */
17713:
17814: #include "system.h"
17915:
18016: /* Refer to the device datasheet for information about available
18117: oscillator configurations and to compiler documentation for macro details. */
18218: void ConfigureOscillator(void)
18319: {
18420:
18521: /*If the PIC12 device has an OSCCAL value, the HiTech Compiler provides
18622: a macro called _READ_OSCCAL_DATA which can be loaded using this: */
18723:
18824: /* TODO Configure OSCCAL if the device has an OSCCAL register */
18925:
19026: #if 0
19127:
19228: OSCCAL=_READ_OSCCAL_DATA(); /* _READ_OSCCAL_DATA macro unloads cal memory */
19329:
19430: #endif
19531:
19632: /*Not all PIC12 devices require this.
19733:
19834: /* TODO Add clock switching code if appropriate. */
19935:
20036: /* Typical actions in this function are to tweak the oscillator tuning
20137: register, select new clock sources, and to wait until new clock sources
20238: are stable before resuming execution of the main project. */
20339:
20440: // Enable 32MHz internal clock 5.2.2.6
20541: OSCCONbits.SCS = 0b00;
2060768 30FC MOVLW 0xFC
2070769 0021 MOVLB 0x1
208076A 0599 ANDWF T1GCON, F
20942: OSCCONbits.IRCF = 0b1110;
210076B 0819 MOVF T1GCON, W
211076C 3987 ANDLW 0x87
212076D 3870 IORLW 0x70
213076E 0099 MOVWF T1GCON
21443: OSCCONbits.SPLLEN = 1;
215076F 1799 BSF T1GCON, 0x7
21644:
21745:
21846: }
2190770 0008 RETURN
220--- /home/justin/MPLABXProjects/led_test.X/main.c -----------------------------------------------------
2211: /******************************************************************************/
2222: /* Files to Include */
2233: /******************************************************************************/
2244:
2255: #if defined(__XC)
2266: #include <xc.h> /* XC8 General Include File */
2277: #elif defined(HI_TECH_C)
2288: #include <htc.h> /* HiTech General Include File */
2299: #endif
23010:
23111: #include <stdint.h> /* For uint8_t definition */
23212: #include <stdbool.h> /* For true/false definition */
23313:
23414: #include "system.h" /* System funct/params, like osc/peripheral config */
23515: #include "user.h" /* User funct/params, such as InitApp */
23616:
23717: #include "ws2811.h"
23818:
23919: /******************************************************************************/
24020: /* User Global Variable Declaration */
24121: /******************************************************************************/
24222:
24323: /* i.e. uint8_t <variable_name>; */
24424:
24525: /******************************************************************************/
24626: /* Main Program */
24727: /******************************************************************************/
24828:
24929: void main(void)
25030: {
25131: /* Configure the oscillator for the device */
25232: ConfigureOscillator();
253078B 3187 MOVLP 0x7
254078C 2768 CALL 0x768
255078D 3187 MOVLP 0x7
25633:
25734: /* Initialize I/O and Peripherals for application */
25835: InitApp();
259078E 3187 MOVLP 0x7
260078F 2771 CALL 0x771
2610790 3187 MOVLP 0x7
26236:
26337: for (int j=0; j<RGB_COUNT; j+=3) {
2640791 01F5 CLRF j
2650792 01F6 CLRF 0x76
2660793 0876 MOVF 0x76, W
2670794 3A80 XORLW 0x80
2680795 00FF MOVWF 0x7F
2690796 3080 MOVLW 0x80
2700797 027F SUBWF 0x7F, W
2710798 1D03 BTFSS STATUS, 0x2
2720799 2F9C GOTO 0x79C
273079A 3018 MOVLW 0x18
274079B 0275 SUBWF j, W
275079C 1C03 BTFSS STATUS, 0x0
276079D 2F9F GOTO 0x79F
277079E 2FA0 GOTO 0x7A0
278079F 2FA2 GOTO 0x7A2
27907A0 2FD2 GOTO 0x7D2
28007A1 2FD2 GOTO 0x7D2
28107BF 3003 MOVLW 0x3
28207C0 07F5 ADDWF j, F
28307C1 3000 MOVLW 0x0
28407C2 3DF6 ADDWFC 0x76, F
28507C3 0876 MOVF 0x76, W
28607C4 3A80 XORLW 0x80
28707C5 00FF MOVWF 0x7F
28807C6 3080 MOVLW 0x80
28907C7 027F SUBWF 0x7F, W
29007C8 1D03 BTFSS STATUS, 0x2
29107C9 2FCC GOTO 0x7CC
29207CA 3018 MOVLW 0x18
29307CB 0275 SUBWF j, W
29407CC 1C03 BTFSS STATUS, 0x0
29507CD 2FCF GOTO 0x7CF
29607CE 2FD0 GOTO 0x7D0
29707CF 2FA2 GOTO 0x7A2
29807D0 2FD2 GOTO 0x7D2
29907D1 2FD2 GOTO 0x7D2
30038: rgbdata[j+0] = 0x20; // R
30107A2 0875 MOVF j, W
30207A3 0709 ADDWF WREG, W
30307A4 3E20 ADDLW 0x20
30407A5 0086 MOVWF FSR1L
30507A6 0187 CLRF FSR1H
30607A7 3020 MOVLW 0x20
30707A8 3FC0 MOVWI [0]FSR1
30807A9 3000 MOVLW 0x0
30907AA 3FC1 MOVWI [1]FSR1
31039: rgbdata[j+1] = 0x20; // G
31107AB 0875 MOVF j, W
31207AC 0709 ADDWF WREG, W
31307AD 3E02 ADDLW 0x2
31407AE 3E20 ADDLW 0x20
31507AF 0086 MOVWF FSR1L
31607B0 0187 CLRF FSR1H
31707B1 3020 MOVLW 0x20
31807B2 3FC0 MOVWI [0]FSR1
31907B3 3000 MOVLW 0x0
32007B4 3FC1 MOVWI [1]FSR1
32140: rgbdata[j+2] = 0x00; // B
32207B5 0875 MOVF j, W
32307B6 0709 ADDWF WREG, W
32407B7 3E04 ADDLW 0x4
32507B8 3E20 ADDLW 0x20
32607B9 0086 MOVWF FSR1L
32707BA 0187 CLRF FSR1H
32807BB 3000 MOVLW 0x0
32907BC 3FC0 MOVWI [0]FSR1
33007BD 3000 MOVLW 0x0
33107BE 3FC1 MOVWI [1]FSR1
33241: }
33342:
33443: while(1)
33507FD 2FD2 GOTO 0x7D2
33644: {
33745: ws2811_start();
33807D2 3187 MOVLP 0x7
33907D3 2760 CALL 0x760
34007D4 3187 MOVLP 0x7
34146:
34247: for (int j=0; j<10; j++)
34307D5 01F3 CLRF j_41
34407D6 01F4 CLRF 0x74
34507D7 0874 MOVF 0x74, W
34607D8 3A80 XORLW 0x80
34707D9 00FF MOVWF 0x7F
34807DA 3080 MOVLW 0x80
34907DB 027F SUBWF 0x7F, W
35007DC 1D03 BTFSS STATUS, 0x2
35107DD 2FE0 GOTO 0x7E0
35207DE 300A MOVLW 0xA
35307DF 0273 SUBWF j_41, W
35407E0 1C03 BTFSS STATUS, 0x0
35507E1 2FE3 GOTO 0x7E3
35607E2 2FE4 GOTO 0x7E4
35707E3 2FE6 GOTO 0x7E6
35807E4 2FD2 GOTO 0x7D2
35907E5 2FD2 GOTO 0x7D2
36007EA 3001 MOVLW 0x1
36107EB 07F3 ADDWF j_41, F
36207EC 3000 MOVLW 0x0
36307ED 3DF4 ADDWFC 0x74, F
36407EE 0874 MOVF 0x74, W
36507EF 3A80 XORLW 0x80
36607F0 00FF MOVWF 0x7F
36707F1 3080 MOVLW 0x80
36807F2 027F SUBWF 0x7F, W
36907F3 1D03 BTFSS STATUS, 0x2
37007F4 2FF7 GOTO 0x7F7
37107F5 300A MOVLW 0xA
37207F6 0273 SUBWF j_41, W
37307F7 1C03 BTFSS STATUS, 0x0
37407F8 2FFA GOTO 0x7FA
37507F9 2FFB GOTO 0x7FB
37607FA 2FE6 GOTO 0x7E6
37707FB 2FD2 GOTO 0x7D2
37807FC 2FD2 GOTO 0x7D2
37948: DelayMs(100);
38007E6 30B1 MOVLW 0xB1
38107E7 00F2 MOVWF 0x72
38207E8 0BF2 DECFSZ 0x72, F
38307E9 2FE8 GOTO 0x7E8
38449:
38550: }
38651: }
38707FE 3180 MOVLP 0x0
38852:
389--- /home/justin/MPLABXProjects/led_test.X/interrupts.c -----------------------------------------------
3901: /******************************************************************************/
3912: /*Files to Include */
3923: /******************************************************************************/
3934:
3945: #if defined(__XC)
3956: #include <xc.h> /* XC8 General Include File */
3967: #elif defined(HI_TECH_C)
3978: #include <htc.h> /* HiTech General Include File */
3989: #endif
39910:
40011: #include <stdint.h> /* For uint8_t definition */
40112: #include <stdbool.h> /* For true/false definition */
40213:
40314: #include "ws2811.h"
40415:
40516: /******************************************************************************/
40617: /* Interrupt Routines */
40718: /******************************************************************************/
40819:
40920: /* Baseline devices don't have interrupts. Unfortunately the baseline detection
41021: * macro is named _PIC12 */
41122:
41223:
41324:
41425: void interrupt isr(void)
41526: {
4160004 3180 MOVLP 0x0
41727: /* This code stub shows general interrupt handling. Note that these
41828: conditional statements are not handled within 3 seperate if blocks.
41929: Do not use a seperate if block for each interrupt flag to avoid run
42030: time errors. */
42131:
42232: #if 0
42333: if (PIR1bits.SSP1IF) {
42434: ws2811_int();
42535: }
42636: #endif
42737: }
4280008 0870 MOVF 0x70, W
42938:
43039: