Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Are numerous sleep instructions possible in a program?

Status
Not open for further replies.

Steve311

Member
Hi All;
I am writing an .asm to sample analog inputs. I would like these inputs to be sampled every 10 to 15 seconds or so.

I have a series of 4 inputs being sampled, therefore I have 4 seperate sections in my code which use the ADC and read the inputs.

Is it possible to put the sleep instruction at the beginning of the ADC code for each of the sample set?

Or is only one sleep instruction permitted?

And also, could someone please explain to me the verbal meaning (not the datasheet meaning) of the instructions: org 0x00 and org 0x04?

Thanks everyone,
Steve
 
You can call the sleep function as often as you'd like permitting you're using it properly. It's not something only permitted once in your code.

I'm not sure what you mean by verbal meaning but I'll attempt to help anyway. 0x00 is the beginning of the code space for your PIC. 0x04 is the address that's jumped to when an interrupt occurs. To avoid running your ISR on power up normally one of the first instructions jumps that memory address (0x04).
 
Continuing on from LTX71CM, the org 0x00 tells the assembler to locate the instructions following starting at location 0x00, while org 0x04 tells it to assemble the instructions following at address 0x04 onwards.
 
Great guys thanks for your responses.

How critical is it to use org 0x04 and org 0x00 while using the sleep function (awakening from the WDT)??

And are there any tips inparitcular you could give me for using the sleep instruction and the WDT together??

Thanks again..
 
What part are you using? If it's a low range one, it might wake up by doing a reset; otherwise it'll probably just continue on from the sleep instruction when it wakes up.
 
When all else fails, check the datasheet. Excerpt attached (see the conditions and the PC - program counter - details).

Re your question about the importance of org 4 when used with sleep - it's of no more importance than when not using sleep; i.e. if GIE is clear, the uC will never jump to addr 4 on an enabled interrupt, but if GIE is set, it will.

To wake up after the ADC conversion is done, make sure the ADIE is set. Note that ADIF will have to be cleared in software.
 

Attachments

  • wake up.gif
    wake up.gif
    7.4 KB · Views: 163
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top