Rsout stops working/hangs


+ Reply to Thread
Results 1 to 3 of 3

Thread: Rsout stops working/hangs18 days old

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    218
    Thumbs Up
    Received: 9
    Given: 20
    Total Downloaded
    751.86 MB

    0 Not allowed!

    Default Rsout stops working/hangs

    Hi,
    I have a dsPic33Fj128mc706A running to drive a bldc motor, 2 dc motors and 2 uart interfaces. I'm using the PicKit2 to program the dsPic. Lately i thought why not use the UART tool in the PicKitPlus software to read/ debug the device. to achieve this i setup the port like:
    Code:
    'portb.7 TX via PicKit2    Declare Serial_Baud 9600
        Declare RsOut_Pace 100
        Declare RsOut_Pin PORTB.7
        Declare RsOut_Mode 0
        Output PORTB.7
    After programming the device i get an serial read through the pickit as expected. The thing is whenever i activate the BLDC motor the data output in the PicKit serial terminal hangs. the led indicator on the pickit2 keeps blinking which tells me data is still send from the dspic.
    By playing with the baudrate in the PIckit software terminal i get some readable data.
    What can cause this?
    I assume it has to do something with the generated interrupts but i'm not sure. I have a 1000Hz timer1 ISR, a timer2&3 combined ISR, 1 UART Rx ISR and the 3 Hall Input captures.

    How do i manage the ISR priority in such a case? (This to perhaps avoid this strange Rsout behaviour)

    The datasheet tells me there are Interrupt priority registers available but i do not know how to determine the right priority.

    Thanks for any help

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    534
    Thumbs Up
    Received: 31
    Given: 7
    Total Downloaded
    3.87 GB

    0 Not allowed!

    Default Re: Rsout stops working/hangs

    Only had a brief scan of the data sheet but it looks to like you first have to enable the relevant interrupts via the IEC registers.

    Then you set the priority level of the relevant interrupts via the relevant bits of the IPC registers, for example...
    If you want the Timer1 interrupt to have a medium Priority then you set bits 14:12 of register IPC0 to 100 (4) as 7 is the highest priority and 1 the lowest.
    If you want the Input Capture Channel 1 interrupt to have a higher priority than that of Timer 1 then set bits 6:4 of register IPC0 to say 101 (5).
    Equally if you want the External Interrupt 0 interrupt to have a lower priority than that of Timer 1 then set bits 2:0 of register IPC0 to say 010 (2).

    Although I am not quite sure if/how that ties into the CPU Interrupt priority level set in the CPU Status register.
    Ultimately it is up to you to determine which interrupts are more important than other and set their priorities respectively, may be a good idea to write down all the interrupts you are using and assign their priority so you have a good overview of their relative priority levels.

    There is a priority level 0 which disables them, you may have to do that while sending data in order to minimise disruption to data transmission or arrange you code so that you only send between interrupts particularly if the data is being bitbashed in software which requires executing a large chunk of code uninterrupted as opposed to using the UART under highest priority interrupt.
    If your BLDCM is similar to those I use (three phase) there are 12 commutation interrupts per revolution so at 4000rpm you have 800 commutation interrupts per second (4000/60)*12 which only leaves you at best (assuming it executed no other code) 1.25mS to transmit all your data between interrupts.
    You may need to run the math on how long it takes you to transmit the data, execute you main loop, handle you interrupt and see how all that compares to the time between commutations at the maximum motor speed to see how well it all runs because (big) if my maths is correct at 4000rpm you can send only 8 bytes between commutation interrupts at 9600 baud.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,513
    Thumbs Up
    Received: 318
    Given: 152
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Rsout stops working/hangs

    Remember.... The Rsout, Rsin, Serout and Serin commands are software based. i.e. Bit-Bashed, so they use software timing for their Baud generation. An interrupt will interfere with the timings of the foreground program because the interrupts are always working in the background, so the timings in the foreground program will slow down because software timings are based upon loops competeting in a particular time based upon the oscillator used, and the interrupt will fire between the loops, thus slowing them down slightly.

    This can be compensated for by altering the Baud rate of the software serial commands, but only as long as the interrupts are evenly balanced to they always take the same amount of time within them. Unfortunately, this is the nature of the beast and there is nothing that can be done to stop the interrupts using time, apart from disabling them when transmitting or receiveing, which rather defeats the object of having the interrupts. :-)

    When using interrupts and serial data it is always advisable to use a USART command because the Baud generator for these is hardware based and an interrupt will not interfere with it, unless it is a very, very complex interrupt that takes a vast amount of time, but then it will interfere with everything in the foreground. :-)

    The priorities of the interrupts will have no effect on the foreground program's timing difference and are to give priorities to the interrupt handling routines. There is a natural order to the priorities by default and these can be changed with a few SFR manipulations, but IMO, they are simply not required 99% of the time.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Serial out stops program from working
    By RGV250 in forum Proton 24
    Replies: 9
    Last Post: 14th May 2016, 15:16
  2. [SOLVED !] PICKIT3 hangs on exit
    By ADLIN SYSTEMS in forum The Lounge
    Replies: 2
    Last Post: 28th July 2015, 23:05
  3. [SOLVED !] SD Card hangs
    By TOSC in forum The Lounge
    Replies: 0
    Last Post: 12th May 2015, 21:46
  4. [SOLVED !] Easy HID stops working!
    By pdgnr in forum Mecanique - IDE
    Replies: 1
    Last Post: 11th March 2006, 12:22
  5. [SOLVED !] Complier Hangs
    By Ron.Taylor in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 22nd August 2005, 11:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts