This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to correctly setup the Brown Out Reset?

Other Parts Discussed in Thread: ENERGIA

How do you go about setting up the BOR? I would like for it to cause an interrupt, which is supposedly the default, but which ISR vector do I need to configure? How do I configure the SysCtl registers to receive this interrupt? What I have done:

SysCtlResetBehaviorSet(SYSCTL_ONRST_BOR_SYS);

SysCtlVoltageEventConfig(SYSCTL_VEVENT_VDDCBO_INT |  SYSCTL_VEVENT_VDDABO_INT | SYSCTL_VEVENT_VDDBO_INT);

But now what? What interrupt to I need to enable/configure? The data sheet says the reset handler, where is this? I don't see it listed in the SysCtlPeriperal list, which is how I am used to setting up interrupts.

Please help.

TM4C129 BTW

  • Hi Alex,

    First pratical part,
    The Reset ISR is already defined in the startup ISR. You can simply edit the handler that is already there to your needs. Remember to check the interrupt cause so your piece of code in there only executes when a BOR occurs. And also, don't forget the other steps on setting a interrupt - enable interrupts (allow interrupts), enable the interrupts you want, etc.

    The reset interrupt should be part of the system control. You said you read that in the datasheet right? Which "chapter" was it? It was 5 correct? Well that is the system control. You can check the interrupts in the datasheet of course but you also want the macros, correct?
    I find it easier to search the source codes. You want something related to the system control correct? Well search sysctl.h and sysctl.c. In this case I'll tell you, it's in sysctl.h and the macro for a BOR flag is SYSCTL_INT_BOR0 (notice that in SysCtlIntEnable() you don't need a base address like most peripherals, after all there's only 1 system control).

    If you are curious on how to see possible interrupt sources from your peripheral:
    When searching the interrupt in the datasheet I find it easier to go to the register map. It might seem stupid "that's harder!", no actually, all peripherals have a RAW and Masked interrupt register, I just search for the word "interrupt" in the register map table and hello! It's there, I chosen to look in "Interrupt Mask Control". Click the "see page" so see the whole register description and there I see all the possible interrupts.
    This works 90% of the times when I want to quickly see the possible interrupts.
    Then of course you can and should check the functional description sections for more info but I think this method saves time in reading a big functional description looking for names when the registers bit field description says most of time in very few words the general idea.
  • Hey Luis,

    Thanks for the information! All this time I was looking in the sysctl.c and didn't give the sysctl.h a chance :/ But now I think I am a little confused. I guess what I am actually looking for is a method to detect that a reset has occurred, or a brown out has occurred. So, instead of the BOR issuing an interrupt, I think I would still want it to reset the device and hold it in reset, but upon startup, I'd like to clarify that a reset has occurred, whether it was brown out or not. So in the end, I think what I need is to 'peek' into the reset/startup ISR as you mentioned. So now I am still a little murky, I don't see a reset macro that I can enable using SysCtlIntEnable(). You mentioned editing the the startup ISR where the reset ISR is present, but how do I do this? I don't see a startup ISR macro either? Im confused :( 

    Thanks for your help again,

    - Alex

  • Take a look at the TivaWare User guide in the System Control Chapter (21 in the version I'm looking at) for SysCtlResetCauseGet and friends.

    You can call this in main, no need to modify the startup just to determine the reset source.

    Robert
  • I agree with Robert, thought it seems you are missing some knowledge.

    The macros for the SysCtlIntEnable are all in the sysctl.h file. It actually says which macros should be used in that function.

    I didn't meant the startup ISR. I meant the startup file. If you check your project you will have there a startup file for your part. Check out what's in there ;)
  • Oh okay, I am developing in Energia and so I was unaware of a startup file being present. Anyways, thanks again for your help, I think I should be able to do what I am looking for now.
  • Hey Robert,

    Good point, didn't think to do this. So what would be the point of configuring an interrupt driven by BOR, does it happen just before reset, or upon startup?
  • Alex LePelch said:
    Good point, didn't think to do this. So what would be the point of configuring an interrupt driven by BOR, does it happen just before reset, or upon startup?

    Instead of reset.  I do that myself because I've found the BOR to be way too sensitive. 

    You could also use it to perform operations prior to a shutdown.

    Robert