[LW Mesh] Interrupt and WDT

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi !

I have questions about interrupts and WDT in LW Mesh.

I'm using ATZB-A24-UFLB module.

1. ATZB-A24-UFLB module has interrupts IRQ_6 and IRQ_7 and I use them LOW.

To enable them :

EICRB = 0x00;
EIMSK = 0xC0;													

//sei();		// instead of this use 

SREG |= (1<<7);

To disable them I can:


//cli();		// do not use

SREG |= 0x7F;		// disable global interrupt enable

or

EIMSK |= 0x80;		// disable IRQ_6	
EIMSK |= 0x40;		// disable IRQ_7	

Is it OK like this?

2. Dealing with WDT(which I plan to use in case if prog. gets stuck, then RESET it) can i use these functions ?

wdt_enable(WDTO_15MS);		// start WDT for 15 ms.
		 
wdt_reset();			// reload counter to 15 ms.			
		
wdt_disable();			// stop WDT if it is started			

Or is there better way ?

Thank you !

Last Edited: Fri. Oct 16, 2015 - 01:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. sei() and cli() are doing exactly the same as SREG manipulation. Don't change global interrupt enable at all, just consider it always on.
Do disable you need to do EIMSK &= ~((1 << 6) | (1 << 7)).

2. Sure, those functions are fine.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi !

I have problem using

wdt_enable(WDTO_15MS);      // start WDT for 15 ms. 
       
wdt_reset();         // reload counter to 15 ms.          
       
wdt_disable();         // stop WDT if it is started       

on new version on LW Mesh.

These functions worked fine on old version.

I would like to do RESET with:

wdt_enable(WDTO_15MS);

but program starts ackting strange.

I can't even reset it with button! That's what I've noticed. I have to do POWER OFF/ON to start working. I'm totally confused here.

Do I have to write something in:

ISR(WDT_vect)
{
	
}

or #include something or something else?

Thank you !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There were no any changes that could affect WDT at all. What exactly do you want to achieve with WDT?

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alexru wrote:
There were no any changes that could affect WDT at all. What exactly do you want to achieve with WDT?

I would like to RESET uC as a result of external command.

Like this:

http://support.atmel.com/bin/customer.exe?=&action=viewKbEntry&id=21

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Then here is a code for this:

    wdt_reset();
    WDTCSR = (1 << WDCE) | (1 << WDE);
    WDTCSR = (1 << WDE);
    while (1);

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thnx Alex, but same thing happens with your code.

I've checked fuses and WDTON is not checked and according to datasheet:

Quote:
WDTON Fuse set to “0“ means programmed and “1” means unprogrammed.

My FUSES HIGH = 0x92

That means WDTON = 1 and is unprogrammed.

So in fuses tab I have to check WDTON?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, you don't need to check WDTON just for reset.

What other fuses do you have and what MCU?

This code is from the working application, so it does work.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fuses in picture ATmega1281

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have bootloader enabled. Do you actually have a bootlaoder? If no, then disable it, if yes, make sure that it disables WDT on entry.

Also, disable CKDIV8 if you don't really need it.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It works now !

Many thnx Alex !

But question is:
why it worked with old version of LW Mesh?

I don't use bootlaoder and I haven't changed fuse bits. I've just c&p code form old version and that's all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Initialization code is a bit faster, for example and it was making it in time to disable WDT in HAL_Init().

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi !

I use ATmega128RFA1 and LW_Mesh v1.2.0.

I have problem using:

wdt_enable(WDTO_15MS);      // start WDT for 15 ms. 
        
wdt_reset();         // reload counter to 15 ms.          
        
wdt_disable();         // stop WDT if it is started 

With these functions I would like to:

1) RESET uC as a result of external command
2) reset uC in case of runaway code

Problem is when uC resets this way uC is stuck and my app. doesn't start.
RESET button doesn't help either, only thing that helps is power OFF/ON.

My fuses are in picture.

Thanks !

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In theory, WDT timer keeps running after the reset, but standard HAL_Init() disables it.

So make sure that HAL_Init() is called within 15 ms after the reset. And just for test try to set WDT timeout to 1 second.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alexru wrote:
In theory, WDT timer keeps running after the reset, but standard HAL_Init() disables it.

So make sure that HAL_Init() is called within 15 ms after the reset. And just for test try to set WDT timeout to 1 second.


Thanks Alex !

I've done this as you suggested, but problem is the same.

Any further ideas?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It might be a time to show us some code.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.