Subversion Repositories svnkaklik

Rev

Blame | Last modification | View Log | Download

;/////////////////////////////////////////////////////////////////////////////////
;// Code Generator: BoostBasic Compiler - http://www.sourceboost.com
;// Version       : 6.70
;// License Type  : Pro License
;// Limitations   : PIC18 max code size:Unlimited, max RAM banks:Unlimited
;/////////////////////////////////////////////////////////////////////////////////

'robot

'#pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H


#pragma DATA _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
#pragma DATA _CONFIG2L, _BOR_ON_2L & _BORV_42_2L & _PWRT_ON_2L
#pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
#pragma DATA _CONFIG3H, _CCP2MX_OFF_3H
#pragma DATA _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
#pragma DATA _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L & _CP3_ON_5L
#pragma DATA _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H
#pragma DATA _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
#pragma DATA _CONFIG6H, _WRTC_ON_6H & _WRTB_ON_6H & _WRTD_OFF_6H
#pragma DATA _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
#pragma DATA _CONFIG7H, _EBTRB_ON_7H

#pragma CLOCK_FREQ 40000000

Function receive() As Byte

        If ( (rcsta.OERR = 1) ) Then
020E  A2AB              BTFSS gbl_rcsta,1
0210  D002              BRA     label268438550
0216            label268438550

                rcsta.CREN = 0
0212  98AB              BCF gbl_rcsta,4

        rcsta.CREN = 1
0214  88AB              BSF gbl_rcsta,4

        End If
    Do While (pir1.RCIF = 0)
0216  AA9E              BTFSS gbl_pir1,5
0218  D7FE              BRA     label268438550

        Loop
        receive = rcreg
021A  50AE              MOVF gbl_rcreg, W
021C  6E0A              MOVWF CompTempVarRet489

        
End Function
021E  0012              RETURN


Sub send(c As Byte)

        Do while (pir1 & (1 << TXIF)) = 0 Loop
0204            label268438561
0204  A89E              BTFSS gbl_pir1,4
0206  D7FE              BRA     label268438561

        txreg = c
0208  500A              MOVF send_00000_arg_c, W
020A  6EAD              MOVWF gbl_txreg

End Sub
020C  0012              RETURN


Sub main()

        Dim motors As Byte
        Dim sensors As Byte
        Dim leds As Byte
        Dim leds1 As Byte
        Dim buttons As Byte
        Dim i As Long

        'NASTAVENI IO
        lata=0xFF
0220  6889              SETF gbl_lata

        latb=0
0222  6A8A              CLRF gbl_latb

        latc=0xFF
0224  688B              SETF gbl_latc

        trisa=0xF0
0226  0EF0              MOVLW 0xF0
0228  6E92              MOVWF gbl_trisa

        trisb=0x3F
022A  0E3F              MOVLW 0x3F
022C  6E93              MOVWF gbl_trisb

        trisc=0x9F
022E  0E9F              MOVLW 0x9F
0230  6E94              MOVWF gbl_trisc


        'VYPNOUT ADC
        adcon1=0xC6
0232  0EC6              MOVLW 0xC6
0234  6EC1              MOVWF gbl_adcon1

        adcon0=0xC0
0236  0EC0              MOVLW 0xC0
0238  6EC2              MOVWF gbl_adcon0


        'UART 9600bps
        spbrg=64
023A  0E40              MOVLW 0x40
023C  6EAF              MOVWF gbl_spbrg

        txsta = txsta & ~(1 << BRGH)
023E  0EFB              MOVLW 0xFB
0240  14AC              ANDWF gbl_txsta, W
0242  6EAC              MOVWF gbl_txsta

        txsta = txsta | (1 << TXEN)
0244  0E20              MOVLW 0x20
0246  10AC              IORWF gbl_txsta, W
0248  6EAC              MOVWF gbl_txsta

        rcsta = rcsta | (1 << CREN)
024A  0E10              MOVLW 0x10
024C  10AB              IORWF gbl_rcsta, W
024E  6EAB              MOVWF gbl_rcsta

        rcsta = rcsta | (1 << SPEN)
0250  0E80              MOVLW 0x80
0252  10AB              IORWF gbl_rcsta, W
0254  6EAB              MOVWF gbl_rcsta

                                
        
        leds = 0xFF
0256  6803              SETF main_1_leds

        leds1 = 0x0F 
0258  0E0F              MOVLW 0x0F
025A  6E04              MOVWF main_1_leds1


        motors = 0x00
025C  6A01              CLRF main_1_motors

                
Do while 1
025E            label268438595

                
                buttons = portb
025E  5081              MOVF gbl_portb, W
0260  6E05              MOVWF main_1_buttons

                
                If (buttons.1)=0 Then
0262  B205              BTFSC main_1_buttons,1
0264  D022              BRA     label268438598
02AA            label268438598

                        i=0
0266  6A06              CLRF main_1_i
0268  6A07              CLRF main_1_i+D'1'
026A  6A08              CLRF main_1_i+D'2'
026C  6A09              CLRF main_1_i+D'3'

                        leds1 = leds1 - 1
026E  0404              DECF main_1_leds1, W
0270  6E04              MOVWF main_1_leds1

                        lata = leds1
0272  5004              MOVF main_1_leds1, W
0274  6E89              MOVWF gbl_lata

                        Do while i <= 500000
0276            label268438603
0276  5009              MOVF main_1_i+D'3', W
0278  0800              SUBLW 0x00
027A  E108              BNZ     label268438604
027C  5008              MOVF main_1_i+D'2', W
027E  0807              SUBLW 0x07
0280  E105              BNZ     label268438604
0282  5007              MOVF main_1_i+D'1', W
0284  08A1              SUBLW 0xA1
0286  E102              BNZ     label268438604
0288  5006              MOVF main_1_i, W
028A  0820              SUBLW 0x20
028C            label268438604
028C  E202              BC      label4026532463
028E  AE09              BTFSS main_1_i+D'3',7
0290  D008              BRA     label268438608
0292            label4026532463

                        i=i+1
0292  2A06              INCF main_1_i, F
0294  B4D8              BTFSC STATUS,Z
0296  2A07              INCF main_1_i+D'1', F
0298  B4D8              BTFSC STATUS,Z
029A  2A08              INCF main_1_i+D'2', F
029C  B4D8              BTFSC STATUS,Z
029E  2A09              INCF main_1_i+D'3', F

                        loop
02A0  D7EA              BRA     label268438603
02A2            label268438608

                        motors = motors + 0x11
02A2  0E11              MOVLW 0x11
02A4  2401              ADDWF main_1_motors, W
02A6  6E01              MOVWF main_1_motors

                
                elseif (buttons.4)=0 Then
02A8  D023              BRA     label268438619
02AA  B805              BTFSC main_1_buttons,4
02AC  D021              BRA     label268438619
02F0            label268438619

                        i=0
02AE  6A06              CLRF main_1_i
02B0  6A07              CLRF main_1_i+D'1'
02B2  6A08              CLRF main_1_i+D'2'
02B4  6A09              CLRF main_1_i+D'3'

                        leds1 = leds1 + 1
02B6  2804              INCF main_1_leds1, W
02B8  6E04              MOVWF main_1_leds1

                        lata = leds1
02BA  5004              MOVF main_1_leds1, W
02BC  6E89              MOVWF gbl_lata

                        Do while i <= 500000
02BE            label268438624
02BE  5009              MOVF main_1_i+D'3', W
02C0  0800              SUBLW 0x00
02C2  E108              BNZ     label268438625
02C4  5008              MOVF main_1_i+D'2', W
02C6  0807              SUBLW 0x07
02C8  E105              BNZ     label268438625
02CA  5007              MOVF main_1_i+D'1', W
02CC  08A1              SUBLW 0xA1
02CE  E102              BNZ     label268438625
02D0  5006              MOVF main_1_i, W
02D2  0820              SUBLW 0x20
02D4            label268438625
02D4  E202              BC      label4026532468
02D6  AE09              BTFSS main_1_i+D'3',7
02D8  D008              BRA     label268438629
02DA            label4026532468

                        i=i+1
02DA  2A06              INCF main_1_i, F
02DC  B4D8              BTFSC STATUS,Z
02DE  2A07              INCF main_1_i+D'1', F
02E0  B4D8              BTFSC STATUS,Z
02E2  2A08              INCF main_1_i+D'2', F
02E4  B4D8              BTFSC STATUS,Z
02E6  2A09              INCF main_1_i+D'3', F

                        loop
02E8  D7EA              BRA     label268438624
02EA            label268438629

                        motors = motors - 0x11
02EA  0E11              MOVLW 0x11
02EC  5C01              SUBWF main_1_motors, W
02EE  6E01              MOVWF main_1_motors

                End If
                
                leds = 0xFF
02F0  6803              SETF main_1_leds

                sensors =0xFF 
02F2  6802              SETF main_1_sensors

                sensors = Call receive()        'prijmi stav cidel senzoru
02F4  EC07F001          CALL receive_00000
02F8  500A              MOVF CompTempVarRet489, W
02FA  6E02              MOVWF main_1_sensors

                'Bity v bajtu sensors
                'BIT3=LEVE SPODNI, BIT2=PRAVE SPODNI, BIT1=LEVE PREDNI, BIT0=PRAVE PREDNI
                'prislusny bit v nule znamena aktivni senzor
                If (sensors.0)=0 Then
02FC  B002              BTFSC main_1_sensors,0
02FE  D003              BRA     label268438643
0306            label268438643

                        'pravy predni senzor aktivni
                        'rozsvit prislusnou LED k senzoru, zatim jen v promenne
                        leds = leds & ~(1 << 1) 'led sviti, kdyz se ji bit znuluje
0300  0EFD              MOVLW 0xFD
0302  1403              ANDWF main_1_leds, W
0304  6E03              MOVWF main_1_leds

                End If
                
                If (sensors.1)=0 Then
0306  B202              BTFSC main_1_sensors,1
0308  D003              BRA     label268438646
0310            label268438646

                        'levy predni senzor aktivni
                        'rozsvit prislusnou LED k senzoru, zatim jen v promenne
                        leds = leds & ~(1 << 2) 'led sviti, kdyz se ji bit znuluje
030A  0EFB              MOVLW 0xFB
030C  1403              ANDWF main_1_leds, W
030E  6E03              MOVWF main_1_leds

                End If

                If (sensors.2)=0 Then
0310  B402              BTFSC main_1_sensors,2
0312  D003              BRA     label268438649
031A            label268438649

                        'pravy spodni senzor aktivni
                        'rozsvit prislusnou LED k senzoru, zatim jen v promenne
                        leds = leds & ~(1 << 0) 'led sviti, kdyz se ji bit znuluje
0314  0EFE              MOVLW 0xFE
0316  1403              ANDWF main_1_leds, W
0318  6E03              MOVWF main_1_leds

                End If
                
                If (sensors.3)=0 Then
031A  B602              BTFSC main_1_sensors,3
031C  D003              BRA     label268438652
0324            label268438652

                        'levy spodni senzor aktivni
                        'rozsvit prislusnou LED k senzoru, zatim jen v promenne
                        leds = leds & ~(1 << 3) 'led sviti, kdyz se ji bit znuluje
031E  0EF7              MOVLW 0xF7
0320  1403              ANDWF main_1_leds, W
0322  6E03              MOVWF main_1_leds

                End If 
                
                
        lata = leds
0324  5003              MOVF main_1_leds, W
0326  6E89              MOVWF gbl_lata

        call send(motors)
0328  5001              MOVF main_1_motors, W
032A  6E0A              MOVWF send_00000_arg_c
032C  EC02F001          CALL send_00000


                
        Loop
0330  D796              BRA     label268438595


        
End Sub


////////////////////////////////////////
// Code with no source :-)
////////////////////////////////////////
0200  EF99F001          GOTO    _startup


0332            _startup
0332  EF10F001          GOTO    main

300000  FEFF            DW 0xFEFF
300002  FEF6            DW 0xFEF6
300004  FEFF            DW 0xFEFF
300006  FFFB            DW 0xFFFB
300008  3FF0            DW 0x3FF0
30000A  9FFF            DW 0x9FFF
30000C  BFFF            DW 0xBFFF