Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
test with dspic33FJ128MC802 [solved]
#1
Sorry for my poor English ^^...
By the way thank you to the developers as DS30 loader...
Before sending any we will start from the beginning …

I chose my pic
Code:
;------------------------------------------------------------------------------
; Device
;------------------------------------------------------------------------------
.equ __33FJ128MC802,         1            ;


Quartz 10Mhz
PLL configuration PLLPRE -> 5Mhz;
VC0 -> 160Mhz ;
PLLPOST -> 80Mhz
Fcy=Fosc/2 = 80 000 000/2 = 40 000 000 = 40Mhz

My FCY is it false?

Code:
;------------------------------------------------------------------------------
; User preferences
;------------------------------------------------------------------------------

        .equiv     FCY,                 40000000        
        .equiv    BLINIT,                3000        
        .equiv    HELLOTRIES,            2            
        .equiv    BLTIME,                3000



I want to use the UART1 ...
And I use on my dsPIC Peripheral Pin Select Registers ....
;RPINR18bits.U1RXR = 10; //U1RX RB10/RP10
;RPOR5bits.RP11R = 3; //U1TX RB11 (=3 veut dire fonction TX)
we must use USE_ALTIO?

Code:
;------------------------------------------------------------------------------
; UART settings
;------------------------------------------------------------------------------        
        .equiv    USE_UART1,            1            
        ;.equiv    USE_UART2,            1            
        ;.equiv    USE_UART3,            1            
        ;.equiv    USE_UART4,            1            
        ;.equ    USE_ALTIO,            1            
        .equiv     BAUDRATE,             115200        
        ;.equiv    USE_ABAUD,            1            
        ;.equiv    USE_BRGH,            1                    
        ;.equiv    USE_TXENABLE,        1                    
        .ifdef USE_TXENABLE
            .equiv    TRISR_TXE,        TRISA        
            .equiv     LATR_TXE,        LATA        
            .equiv    TRISB_TXE,        TRISA1        
            .equiv    LATB_TXE,        RA1            
        .endif

Here if it does not work after I will post answer worth following @ + thank you
Reply
#2
Hi,
You will need to add code to configure PLL. You can do that in this section in ds30loader.s:
Code:
;------------------------------------------------------------------------------
; User specific entry code go here, see also user exit code section at end of file
;------------------------------------------------------------------------------

You also need to modify the PPS template in ds30loader.s

Finally you need to configure the configuration bits.

If haven't done so already, read the manuals.

From the manual
Quote:USE_ALTIO
Uncomment to use alternative I/O for UART1. This setting is only valid for dsPIC30F devices.
More information about the BRGH settings is available in the device datasheet.
Reply
#3
Code:
So to configure the PLL I tried to write just after

;------------------------------------------------------------------------------
; User specific entry code go here, see also user exit code section at end of file
;------------------------------------------------------------------------------

CLKDIVbits.PLLPRE = 0;
PLLFBDbits.PLLDIV = 30;
CLKDIVbits.PLLPOST = 0;

and also


CLKDIV.PLLPRE = 0;
PLLFBD.PLLDIV = 30;
CLKDIV.PLLPOST = 0;

and also

CLKDIV = 0;
PLLFBD = 0x001E;

and also just after .ifdef HAS_PPS same as above

What is good writing?


for PPS I had configured like this:

U1RX -> RPINR18 -> RP10 = 10
RPINR18bits.U1RXR = 10; //U1RX RB10/RP10
RP11 on RPOR5 -> U1TX = 3
RPOR5bits.RP11R = 3; //U1TX RB11/RP11
For information ... This configuration will work for my current program

Code:
        ;----------------------------------------------------------------------
        ; UART/CAN pps config
        ;----------------------------------------------------------------------
        .ifdef HAS_PPS
                ;.error "UART/CAN pps is not configured. Read datasheet and configure pps."            ;xxx remove this line                        
            
                ; ** IMPORTANT **
                ;
                ; THIS CODE IS JUST A TEMPLATE AND WILL MOST LIKELY NOT WORK FOR YOU,
                ; READ THE DATASHEET AND ALTER LINES MARKED WITH XXX
                ;
                ; ** IMPORTANT **

            
                ; Backup, these are restored in exit code at end of file
                ; Changes needs to be done in exit, search for xxx
                mov        RPINR18, WPPSTEMP1        ;xxx
                mov        RPOR5, WPPSTEMP2        ;xxx
    
                ; Receive, map pin (14 = 1110) to uart
                ; 10 = 1010
                bclr    RPINR18, #U1RXR0        ;xxx 0
                bset    RPINR18, #U1RXR1        ;xxx 1
                bclr    RPINR18, #U1RXR2        ;xxx 0
                bset    RPINR18, #U1RXR3        ;xxx 1
                bclr    RPINR18, #U1RXR4        ;xxx 0
                        
                ; Transmit, map uart to pin
                ; fonction U1TX = 3
                bset    RPOR5, #RP11R0            ;xxx 1
                bset    RPOR5, #RP11R1            ;xxx 1
                bclr    RPOR5, #RP11R2            ;xxx 0
                bclr    RPOR5, #RP11R3            ;xxx 0
                bclr    RPOR5, #RP11R4            ;xxx 0    
        .endif



exit:


        .ifdef HAS_PPS
        ;.error "PPS restoration is not configured."        ;xxx remove this line            
        mov        WPPSTEMP1, RPINR18        ;xxx restore
        mov        WPPSTEMP2, RPOR5                   ;xxx  pps settings
        .endif

Really thank you for the help @+
Reply
#4
The ds30 Loader free edition firmware is written in assembler. Your configuration code also need to be written in assembler.
You can read the other code and the Microchip documentation to understand how it is done.
Reply
#5
Well received ... Now I understand better now ... I could try again in several weeks ... I repost here if I go into the configuration ... thank you again ...
Reply
#6
Hello again blocked ...

my setup that works with my program

CLKDIVbits.PLLPRE = 0;
PLLFBDbits.PLLDIV = 30;
CLKDIVbits.PLLPOST = 0;

In firmware ds30loader I wrote as

Code:
; *** START FOR MODIFICATION GLUONPILOT ***
; Apply the PLL config to make it safe runs at 40MHz, just like our firmware
; CLKDIVbits.PLLPRE = 0 / / N1 = 2
CLR W0
mov.w W0, 0x0744
; CLKDIVbits.PLLPOST = 0 / / N2 = 2

; PLLFBDbits.PLLDIV = 30;
mov.w # 30, W0
mov.w W0, 0x0746

I also added a ca in the "User Specific entry" to see if my program is running well

Code:
; TEST LED Lighting
BSET AD1PCFGL, # 4
bclr TRISA, # TRISA4
    BSET PORTA, # 4

My output is activated but I have nothing on the UART1

In your opinion what I should look?

I put in my code link you never know ... thank you

http://dl.free.fr/eU5VULYcK
Reply
#7
That looks ok. But you should use the register names:
Code:
clr W0
mov.w W0, CLKDIV
mov.w #30, W0
mov W0, PLLFBD

I am not able to download the file. Please use an English site or attached the file to a forum post.
Reply
#8
Well thank you ca still does not work but I continued to search ...
And here's the code ... thank you to soon

edit:
The part below is for she parameterize dsPIC33? or is it just you setting pins by UART / CAN "PPS" configuration

Code:
. USE_TXENABLE equiv, 1; xxx uncomment to use a tx enable pin
. ifdef USE_TXENABLE
. equ TXE_DELAY, 10; xxx us in time to WAIT BEFORE Transmitting After pulling the enable pin high tx
. equiv TRISR_TXE, TRISA; xxx Containing Tris tx enable register
. equiv LATR_TXE, LATA; xxx harbor Containing tx enable register
. equiv TRISB_TXE, TRISA1; xxx bit for tx enable sorting
. equiv LATB_TXE, RA1, xxx Port enable bit for tx
. endif


Attached Files
.zip   firmware 16-bit DsPIC33FJ.zip (Size: 92.53 KB / Downloads: 19)
Reply
#9
I tried with firmware ds30_Loader_120325 ...
Now the detection of PIC with the GUI is ...
The transfer seems to be too ...

Code:
Initiating write ...
       Searching for bl. . . . . . .
       Found dsPIC33FJ128MC802 fw ver. 4.0.3
       Waiting for bootloader ... ok To Be Ready
       Hex file successfully parsed
       Writing flash .... ok
       20.2 kB Tx / Rx 121 bytes / s 31.3
       Write Successfully Completed

The program I have loaded does not execute correctly ..
I have the "interrupt" of my TIMER1 that does not execute when my TIMER 2 and 3 apparently no problem...
for example I can blink an LED ...
For information I use mikroC compiler ...

thank you to soon ...
Reply
#10
Well the timer1 does not work ... but others 2,3,4 and 5 is good ...
So I post my code if it can help someone ...
For information I use a 10Mhz crystal and the bootloader for UART1 on pins RB10 (RX) and RB11 (TX) ...


Thank you again for this really effective bootloader @ +


Attached Files
.zip   firmware 16-bit Dspic33FJ128MC802.zip (Size: 77.84 KB / Downloads: 40)
Reply
#11
How do you configure timer1?
Reply
#12
With my C compiler

Code:
//IPC0bits.T1IP = 0;                  //T1IP<2:0>: Timer1 Interrupt Priority bits  111 = Interrupt is priority 7 (highest priority interrupt)
IEC0bits.T1IE = 1;                  //T1IE: Timer1 Interrupt Enable bit
T1CONbits.TCS = 0;                  //0 = Internal clock (FCY)
T1CONbits.TSYNC = 0;
T1CONbits.TCKPS = 0b00;             //TCKPS<1:0>: Timerx Input Clock Prescale Select bits
T1CONbits.TGATE = 0;
T1CONbits.TSIDL = 0;
T1CONbits.TON = 0;                 //TON: Timer1 On bit 1 = Starts 16-bit
TMR1 = 25575 ;

and here is what he does in assembler

Code:
;Robot#3.c,1408 ::                 IEC0bits.T1IE = 1;                  //T1IE: Timer1 Interrupt Enable bit
        BSET        IEC0bits, #3
;Robot#3.c,1409 ::                 T1CONbits.TCS = 0;                  //0 = Internal clock (FCY)
        BCLR        T1CONbits, #1
;Robot#3.c,1410 ::                 T1CONbits.TSYNC = 0;
        BCLR        T1CONbits, #2
;Robot#3.c,1411 ::                 T1CONbits.TCKPS = 0b00;             //TCKPS<1:0>: Timerx Input Clock Prescale Select bits
        MOV        #lo_addr(T1CONbits), W0
        MOV.B        [W0], W1
        MOV.B        #207, W0
        AND.B        W1, W0, W1
        MOV        #lo_addr(T1CONbits), W0
        MOV.B        W1, [W0]
;Robot#3.c,1412 ::                 T1CONbits.TGATE = 0;
        BCLR        T1CONbits, #6
;Robot#3.c,1413 ::                 T1CONbits.TSIDL = 0;
        BCLR        T1CONbits, #13
;Robot#3.c,1414 ::                 T1CONbits.TON = 0;                 //TON: Timer1 On bit 1 = Starts 16-bit Timer1
        BCLR        T1CONbits, #15
;Robot#3.c,1415 ::                 TMR1 = 25575 ;
        MOV        #25575, W0
        MOV        WREG, TMR1

And when I use the interrupt

Code:
void T1Interrupt() iv IVT_ADDR_T1INTERRUPT{

//...Code

//TMR1 = 25575;
TMR1 = 0;

//RAZ Timer1 Interrupt Flag Status bit
IFS0bits.T1IF = 0 ;
}

And when I use the interrupt in asm

Code:
;Robot#3.c,574 ::                 void T1Interrupt() iv IVT_ADDR_T1INTERRUPT{
;Robot#3.c,578 ::                 TMR1 = 0;
        CLR        TMR1
;Robot#3.c,581 ::                 IFS0bits.T1IF = 0 ;
        BCLR        IFS0bits, #3

Thank you for the attention ... and see you soon ... bye and sorry for my english again ^^
Reply
#13
You need to assigne an interrupt priority that is higher than the core priority.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)