PIC18F47J53 A/D muundi probleem
#5
(21-02-2011, 09:53 AM)andrei Kirjutas: Andmeleht räägib TRISA bittide seadistamisest, aga siintoodud koodis pole neist märkigi. Kas olen midagi kahe silma vahele jätnud?
Ei, portide suunad määran hiljem. Kogu init on selline:
Kood:
Init:            call    dly
                movlb    0x0E                    ; PPS on pangas 14.
                movlw    0x55                    ; unlock
                movwf    EECON2
                movlw    0xAA
                movwf    EECON2
                bcf        PPSCON,IOLOCK            ; write protect OHV
                movlw    .24                        ; seome RxD2 pinniga RP24
                movwf    RPINR16
                movlw    0x06                    ; seome TxD2 pinniga RP23
                movwf    RPOR23
                movlw    .20                        ; seome SDI2 pinniga RP20
                movwf    RPINR21
                movlw    .4                        ; seome INT1 pinniga RP4
                movwf    RPINR1
                movlw    .5                        ; seome INT2 pinniga RP5
                movwf    RPINR2
                movlw    .10                        ; seome SDO2 pinniga RP19
                movwf    RPOR19
                movlw    .11                        ; seome SCK2 pinniga RP21
                movwf    RPOR21

                movlw    .14                        ; seome PWM1 pinniga RP7
                movwf    RPOR7
                movlw    .15                        ; seome PWM2 pinniga RP8
                movwf    RPOR7
                movlw    .16                        ; seome PWM3 pinniga RP9
                movwf    RPOR7
                movlw    .17                        ; seome PWM4 pinniga RP10
                movwf    RPOR7
                movlw    .14                        ; seome PWM5 pinniga RP0 (enhanced PWM out channel A)
                movwf    RPOR0
                movlw    .15                        ; seome PWM6 pinniga RP1 (enhanced PWM out channel B)
                movwf    RPOR1
;---- kell -----------------------
                movlb     0x0F                     ;RTCCFG is banked
                bsf        RTCCFG,RTCWREN
                movlw    0xB3                    ; kell sees, lubame väärtusi kirjutada, loeme alati õigesti :)
                movff    WREG,RTCCFG
                movlw    0x00                    ; kal. koef 0
                movff    WREG,RTCCAL
                movlw    0x04                    ; kella takt sisemine, PMP kasutab Šhmidti puhvreid
                movff    WREG,PADCFG1
; **** A/D ****
                movlw    0x03
                movwf    ANCON0                    ; AN2,3,4,5,6,7 on analoogsisendid
                movlw    0x9D
                movwf    ANCON1                    ; bangap ref. ON, AN9 on analoogsisend

                movlw    0x55                    ; luckku tagasi
                movwf    EECON2
                movlw    0xAA
                movwf    EECON2
                bsf        PPSCON,IOLOCK            ; write protect ON
                movlb    0x00
;*******************************
                bsf        OSCTUNE,PLLEN            ; See lollakas tahab siitkaudu PLLi sisse lülatamist...vist
                bsf        OSCTUNE,INTSRC            ; 31.25 kHz device clock derived from 8 MHz INTOSC source (divide-by-256 enabled)
                movlw    0x74
                movwf    OSCCON
                  clrf    STATUS                    ; nullime kõik võimaliku
                clrf    INTCON    
                clrf    PIR1
                clrf    PIR2
                clrf    PIR3
                clrf    PIE1
                clrf    PIE2
                clrf    PIE3
; **** üldkonf ****
                movlw    0x00
                movwf    INTCON2                    ; pull-up takid OHV, reageerib langevatele frontidele
                movlb    0x0F
                movlw    0x00
                movff    WREG,PMCONH                ; paralleelport OHV
                movff    WREG,PMCONL
                movff    WREG,PMMODEH
                movff    WREG,PMMODEL
                movff    WREG,PMEH
                movff    WREG,PMEL
                movlb    0x00
; **** A/D ****
                movlw    v_bat                    ; mõõdame AN5 (toide), muundi tööle ja stopp.
                movwf    ADCON0
                movlw    0x96                    ; 1001 0110 B'10000110';0xBE;
                movwf    ADCON1                    ; paremale, 4 Tad, F/64
; **** komparaatorid OHV *******
                movlw    0x07
                movwf    CM1CON
                movwf    CM2CON
                movlb    0x0F
                movwf    CM3CON
                movlb    0x00
                clrf    CVRCON
; **** pordid ****
                clrf    PCLATH    
                clrf    PORTD    
                clrf    PORTC    
                clrf    PORTB    
                clrf    PORTA
                clrf    PORTE
                MOVLW    B'11111100'
                MOVWF    TRISA                    ;  2* kvarts, gyro-yaw, konde, gyro-y, gyro-x,srv6,srv5
                MOVLW    B'00001111'
                MOVWF    TRISB                    ; srv4..1, gyro temper, acc-y, acc-x, ppm sisend
                MOVLW    B'10111100'                ; NB! Tx peab olema väljund !
                MOVWF    TRISC                    ; GPS serial, USB, vusb, UD, LEDS, LEDP
                MOVLW    B'10000110'
                MOVWF    TRISD                    ; side serial (USART2), SD_CS, SCK, SDI, SDO, CDI, F_CS
                MOVLW    B'00111111'    
                MOVWF    TRISE                    ; -, MCLR, Press, Ibat, Vbat. Dj E-pordi pull-upid OFF

                MOVLW    B'11111100'                ; portide lähteseisud paika
                movwf    PORTA                
                MOVLW    B'00001111'                
                movwf    PORTB
                MOVLW    B'11111100'            
                movwf    PORTC
                MOVLW    B'11000000'
                movwf    PORTD
                MOVLW    B'00001111'
                movwf    PORTE
;---- serial port 1 --------------                 ; side GPS'iga
                movlw    B'00100110'                ; 8 bitine saade
                movwf    TXSTA1
                movlw    B'10010000'                ; 8-bitine vv
                movwf    RCSTA1
                nop
                nop
                nop
                nop
                bcf        BAUDCON2,BRG16
                bcf        TXSTA1,SYNC
                bcf        TXSTA1,BRGH
                bcf        PIR1,RC1IF                
;                bsf        PIE1,RC1IE                ; luba RC1 int
                movlw    .155                    ; baudrate = 4800 @ 48 MHz
                movwf    SPBRG1        
;---- serial port 2 --------------                 ; side ground control'iga
                movlw    B'00100110'                ; 8 bitine saade
                movwf    TXSTA2
                movlw    B'10010000'                ; 8-bitine vv
                movwf    RCSTA2
                nop
                nop
                nop
                nop
                bcf        BAUDCON2,BRG16
                bcf        TXSTA2,SYNC
                bsf        TXSTA2,BRGH
                bcf        PIR3,RC2IF                
;                bsf        PIE3,RC2IE                ; luba RC2 int
                movlw    .25                        ; baudrate = 115200 @ 48 MHz
                movwf    SPBRG2        
;*** PWM ja Taimerid ***
                movlw    0x00;0x0F
                movwf    CCP4CON                    ; moodulid 4..7 PWMi režiimi
                movwf    CCP5CON    
                movwf    CCP6CON    
                movwf    CCP7CON    

                movwf    CCP1CON    
                movwf    CCP2CON    
                movwf    CCP3CON    
    bcf    PIR1,ADIF
    BSF ADCON0,ADON ;Enable A/D module
    BSF ADCON1,ADCAL ;Enable Calibration
    BSF ADCON0,GO ;Start a dummy A/D conversion
CALIBRATION ;
    BTFSC ADCON0,GO ;Wait for the dummy conversion to finish
    BRA CALIBRATION ;
    BCF ADCON1,ADCAL ;Calibration done, turn off calibration enable
;Proceed with the actual A/D conversion

;********************** EI LÕPETA MUUNDAMIST !!! **************************
                return
Vasta


Sõnumeid selles teemas
PIC18F47J53 A/D muundi probleem - Autor: felch - 20-02-2011, 11:27 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: KaruTEC - 21-02-2011, 01:23 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 21-02-2011, 08:49 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 21-02-2011, 09:53 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 21-02-2011, 10:19 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 21-02-2011, 11:47 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 21-02-2011, 12:03 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 21-02-2011, 01:30 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 21-02-2011, 04:21 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 21-02-2011, 04:57 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 21-02-2011, 09:07 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 21-02-2011, 11:36 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 02-03-2011, 11:32 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 03-03-2011, 12:19 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 03-03-2011, 09:11 AM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 03-03-2011, 01:22 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 03-03-2011, 07:10 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 03-03-2011, 08:03 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 04-03-2011, 05:54 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: andrei - 11-03-2011, 08:01 PM
RE: PIC18F47J53 A/D muundi probleem - Autor: felch - 14-03-2011, 08:55 AM

Alamfoorumi hüpe:


Kasutaja, kes vaatavad seda teemat: 2 külali(st)ne