Re: PIC18F252


Closed Thread
Results 1 to 5 of 5

Thread: Re: PIC18F252

  1. #1
    Join Date
    Jul 2005
    Location
    Midwest
    Posts
    81

    Default Re: PIC18F252

    Hey Group,

    I'm hung up on something really simple, I would like to be able to set a flag in software if the WDT causes a reset. I'm displaying the RCON register bits and getting no change in the value. The WDT is enabled and working i think because my led briefly goes out every few seconds. I've searched the list and just can't get it figured out,

    Thanks,
    Steve
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    DEFINE NO_CLRWDT 1

    Stops PBP from clearing the WDT, but it can't do anything about the bootloader.
    As soon as the bootloader executes a clrwdt, it resets the TO timeout bit.

    Without ICSP, or a bootloader that doesn't clear the WDT, you won't be able to detect a WDT timeout.
    <br>
    DT

  3. #3
    Join Date
    Jul 2005
    Location
    Midwest
    Posts
    81


    Did you find this post helpful? Yes | No

    Smile

    Hi Darrel,

    Thanks for the info. If you have a minute, could you explain a little different? Is the boot loader software really interferring with the WDT? ...lol

    I'm trying to use the WDT to escape from a SERIN command with timeout where the baud rate of the PIC and peripheral are different, maybe there is a better way?

    Sincerely,

    Steve

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Steve_88 View Post
    Is the boot loader software really interfering with the WDT?
    I guess it depends on the bootloader.

    Before answering last time, I imported the Mecanique loader for the 18F252 into MPLAB, just to make sure.

    On any reset, there is a period of time that the loader waits for activity from the USART. If it sees activity, it jumps to the bootloader, and if not, it times out and jumps to the user program.

    During that period, it has to make sure the WDT doesn't timeout, so it uses the CLRWDT instruction.

    When CLRWDT is executed, it sets the RCON TO (timeout) bit to 1, which means that no timeout has occurred. Anytime you want to catch a WDT reset, you have to do it at the very beginning of the program, before any CLRWDT instructions have been executed. But since the bootloader itself resets it, you can't.

    I'm trying to use the WDT to escape from a SERIN command with timeout where the baud rate of the PIC and peripheral are different, maybe there is a better way?
    There are 2 better ways that I can think of.

    1. Use ICSP instead of a bootloader.

    2. Use SERIN2. Set a very long timeout period in the SERIN2 statement. Then use interrupts with a timer for the timeout period.

    When the timeout expires, clear the PBP system variable that is tracking the SERIN2's timeout. Which should cause the SERIN2 statement to terminate.

    If you decide to go route #2, I can search through the library to find out which system vars to use. But I would suggest just using ICSP.

    hth,

    Added:

    3. Don't use the bootloader. Which frees up the USART. Then use the USART for the serial communications.

    If the USART is receiving data at a different baud rate than expected, it will throw a Framing Error immediately, so you don't need to worry about the timeout.
    DT

  5. #5
    Join Date
    Jul 2005
    Location
    Midwest
    Posts
    81


    Did you find this post helpful? Yes | No

    Smile

    Hi Darrel,

    Thanks for the explanation, it makes sense now

    I think I'll leave the issue alone for now, it's not really critical for my project.

    Thanks again,

    Steve

Similar Threads

  1. firmware code for pic18f252
    By babalola in forum Off Topic
    Replies: 7
    Last Post: - 8th May 2008, 12:10
  2. Migrating PIC16F876a to PIC18F252
    By cohenjdc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st June 2007, 13:55
  3. pic18f252 hserout problem
    By edysan in forum Serial
    Replies: 4
    Last Post: - 16th June 2006, 20:46
  4. DATA on a PIC18F252
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th October 2005, 09:05
  5. Pic18f252
    By Sphere in forum General
    Replies: 4
    Last Post: - 30th September 2005, 23:10

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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