• AVR Freaks

Helpful ReplyHot!30F4011, dsPIC is resetting itself after operation on TRISB register during debugging step

Author
_dex
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
2018/08/28 09:37:58 (permalink)
0

30F4011, dsPIC is resetting itself after operation on TRISB register during debugging step

I am back in to programming of dsPIC after few years.. After I changed pic from 30F4013 to 30F4011 I discovered a problem which I have not seen on 4013. The problem can be discovered during debugging. In run mode the PIC is working. However when I go step by step (ICD2 and PICKIT3) the problem occurs.
 
Whenever I try to write something to TRISB ( to configure the portB) register the PIC is resetted ( ICD2 hanging the MPLAB 8.92/8.53 and the PICKIT3 inform that PK3Err0031: Failed to get PC)
 
--
When the debugger is in run mode and the pic is executing the main Loop, so it seems everything is fine. I see that the LED in main Loop is blinking. Somehow it is skipping the problem with TRISB register. before the manin Loop. When I halt such executing program PICKIT says: PICkit 3 has halted with error(s). I enclose source code in txt file.
 
Question. Why is the pic resetting itself after executing the mov W0,TRISB instruction during step by step debugging and why it is working fine in run mode?
Same code can be debugged on 4013 step by step without any problems.
 
 
.EQU osc,80; 
.EQU sys_freq,(osc/4)
.equ __30F4011, 1 ;
.include "p30f4011.inc";

;...................................................................
;Configuration bits:
config __FOSC, CSW_FSCM_OFF & ECIO_PLL8; ECIO_PLL8;XT_PLL4 ;Turn off clock switching and//bylo HS2_PLL8
                                       ;fail-safe clock monitoring and
                                       ;use the Quarz HS2(divideby2) with PLLx8 as the
                                       ;system clock
config __FWDT, WDT_OFF ;Turn off Watchdog Timer
config __FBORPOR, PBOR_ON & BORV27 & PWRT_16 & MCLR_EN
                                       ;Set Brown-out Reset voltage and
                                       ;and set Power-up Timer to 16msecs
config __FGS, CODE_PROT_OFF ;Set Code Protection Off for the
;...................................................................
.global __reset;


.text ;start Code section
__reset:
MOV #__SP_init, W15 ;Initalize the Stack Pointer
MOV #__SPLIM_init, W0 ;Initialize the Stack Pointer Limit Register
MOV w0, SPLIM
NOP

;........................PRescaler config.......................
 mov OSCCON,W14 ;Prescaler change
 bclr W14,#(POST1)
 bclr W14,#(POST0)

 mov #OSCCONL,w1 ; pointer to OSCCONL
 mov.b #0x46,w2 ; fidst unlock code
 mov.b #0x57,w3 ; second unlock code
 mov.b w2,[w1] ; write first unlock code
 mov.b w3,[w1] ; write second unlock code
 mov.b W14,[w1]
;....................PRescaler config end....................


;.....Ports config...................................
clr TRISD; port D as outputs

mov #0b1111111000000000,w0 ;config PORTB 0:9 outputs, rest as inputs
mov W0,TRISB ;<<<<<<<<<<<<<<<<HERE IS the problem<<<<<<<<<<<<<<<<<<<<<<<<<<<
;.......Ports config END...................

;############################## M A I N L O O P #################################

Loop:
 nop
 nop
 nop
 Btg LATD,#RD2; blink YLL LED
 bra Loop

;############################## M A I N L O O P E N D ########################

.end ;End of code in this file


post edited by _dex - 2018/08/28 10:47:12
#1
MBedder
Circuit breaker
  • Total Posts : 6732
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Status: offline
Re: 30F4011, dsPIC is resetting itself after operation on TRISB register during debugging 2018/08/28 11:47:10 (permalink) ☄ Helpfulby _dex 2018/08/28 12:52:07
0
Which port/pins is your ICD/PICkit connected to?
#2
_dex
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
Re: 30F4011, dsPIC is resetting itself after operation on TRISB register during debugging 2018/08/28 12:00:40 (permalink)
0
I did a bridge connections from PIN 8 and 9 to PIN26(EMUC) and 25(EMUD). The reason is the 30F4013 EMUC and EMUD lines were there (pin 8 and 9). I use my own breadbord from my 4013 project. Could it be a reason?
 
In MPLAB SIM, after mov W0,TRISB instruction the TRISB=0x0. ( should be 0xFE00, W0 is 0xFE00 line before).
post edited by _dex - 2018/08/28 12:46:48
#3
_dex
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
Re: 30F4011, dsPIC is resetting itself after operation on TRISB register during debugging 2018/08/28 12:51:51 (permalink)
0
Probably now I understand. I am setting PORTB as the output and then the EMUC and EMUD lines are pulled down or high. Ok this must be a reason MBedderSmile: Smile tommorrow I reconfigure my breadboard.
 
But why in MPLAB SIM TRISB register after assigning its a value is equal 0?
 
-------------
SELF ANSWERED
Some bits are not implemented in TRISB register so the read values are 0.
Resetting was due to setting lines as an outputs while they were bridged with EMUC/D lines which are used to establish communication with the debugger.
post edited by _dex - 2018/08/28 13:09:57
#4
Jump to:
© 2019 APG vNext Commercial Version 4.5