hi
im new in mcu programming and I want to write the program which will generate signal at sampling frequency 1Hz and have active mode and sleep mode to the PIC 16C873
i need help coz im not familier with MPLAB
thanks
So you need to generate a signal of frequecy of 1Hz or you are sampling external data at 1Hz?
Regarding sleep and active modes, you can simply send the device to sleep using SLEEP() function. Activate interrupts before going to sleep. If you need to perform the task and go back to sleep again, simply put the SLEEP() function in while loop. This way, the controller wakes up on interrupt, goes to ISR and comes back into the while loop containing SLEEP().
Take care that after waking from sleep, the controller will perform one code line immediately after the SLEEP() function. So its advisable to put NOP() to avoid any unexpected operation.
At 1 Hz, you would probably need to start a timer interrupt. First you load the times value, and then enable it just before you are about to enter sleep. And as I said before, instead of NOP(), you can place the reloading condition for the timer.
Sleep mode is the state when the controller is not active and vice versa. No code is executed while the Pic is in sleep mode, only an interrpt wakes it up, i.e., it comes in active mode and then executes whatever is required.
I looked into the datasheet and realized that the timer interrupt cannot be used while in sleep mode, as the timer itself is not running.
So, either you dont go into sleep mode or, if you just need to process the current data, you could use a watchdog timer, which would wake the controller from sleep.