Wake PIC16F1825 from sleep with RS232 - serial-port

Is it possible to wake a Microchip PIC16F1825 from sleep using RS232 without looking characters?
Because one of the permissible RX pins supports interrupt on change, I thought this might be possible.
Has anybody implemented this successfully?

Sure!
From datasheet PIC16(L)F1825/1829:
9.1 Wake-up from Sleep
The device can wake-up from Sleep through one of the following events:
1. External Reset input on MCLR pin, if enabled
2. BOR Reset, if enabled
3. POR Reset
4. Watchdog Timer, if enabled
5. Any external interrupt
6. Interrupts by peripherals capable of running
during Sleep (see individual peripheral for more information)
So you can use:
1)External interrupt INTERRUPT-ON-CHANGE, if you are connecting RX pin with one of other pins which is configured as interrupt-on-change.
2)Peripheral interrupt RCIF: USART Receive Interrupt Flag bit. When receiver buffer is full (one UART word is received), an interrupt is pending and your CPU should wake up.

Related

How can I wake Arduino Pro Mini(Sleep mode) with DS1302?

I have Arduino Pro Mini and DS1302 Module.
And I setted arduino going to sleep mode.
How can I wake arduino with DS1302?
First of all, Is that a possible?
(use interrupt code?)
The DS1302 does not have any alarm capability, therefore it can not be used to wake up your Arduino.
You would have to switch to an DS3231 for example, which has two programmable alarms. Those alarms will pull a pin on the DS3231 low, which you can use as an interrupt to wake up your Arduino.

Arduino WDT timer value after external interrupt

I am counting pulses using an external interrupt, but I put the processor to sleep in between pulses using wdt_enable, using the 8-second interval.
When the interrupt occurs and the processor wakes up to service the interrupt, is it possible to find out how long into the 8-second period I am? That is, can I read the wdt timer to see how long it has been running (or how long it has to go)?
The ATMEL328p Datasheet Page 51 shows the architecture of the Watchdog. There does not seem to be a method to read back the Watchdog Prescaler. The answer assumes you are using an Arduino with a 328p.

Sending fixed voltage to serial port

I need to monitor if a door is opened. I have a sensor that continues to generate +5V DC as long as the door is shut but drops down to 0V once the door is opened.
I now need to connect the sensor's output wire to PC's serial port and write a program that continuously polls the port.
My thought is that various serial-io parameters such as baud rate, etc., does not matter in my case. For each byte that I read, I expect the value to be 255 (logical 1s) when the door is closed. Otherwise, I will assume that the door has been opened. Is there any flaw in this logic?
I went through Sending a voltage to RS232. It appears I just need to connect the wire to pin 2 (RX). However, for the serial port to receive a logical 1, it seems the voltage needs to be between -3V and -12V. As the voltage my sensor generates is positive, I am thinking I will connect the sensor wire to pin 5 (GND) instead and connect pin 2 to ground. In effect, I inverted the voltage. Will this work?
If this logic is flawed, I may have to buy a voltage inverter.
Finally, I was told that one should not connect anything to pin 5 on a motherboard's serial port. Apparently, it is hardwired to get grounded to the chassis. Is this true? Regards.
Like mentioned in the comments, constant high would not produce 255 bytes.
I would implement this by connecting the GND to GND and connecting the +5 Vdc to the CTS pin, which can be queried for his HIGH / LOW state.
But this is only a hack, you really should use some microcontroller.

Arduino - serial port interrupt

Arduino question on interrupts:
For my Arduino RTC project I need to put my Arduino to sleep until interrupted by either a pin interrupt or by a single char present on the serial port (an arbitrary character) -- How may I achieve this?
I see that a pin interrupt is relatively straightforward, but I'm unable complete this by the serial port [I could poll the serial port, but this wastes energy].
Suggestions welcome

I2C Initialization and draining feature

I'm a beginner. I'm trying to understand about I2C Initialization of TMP102. It is a temperature sensor. It is connected via I2C. So, the initialization must be of I2C. But, my leader told we have to initialize GPIO also in this case, since interrupt pin is connected via GPIO. He also told it is not necessary in other cases. I couldn't understand the original purpose.
Why do we initialize GPIO?
In other cases, where does the slave's interrupt pin gets connected?(if not in GPIO)
Also, in case of large message, TX/RX FIFO may not fit. So, draining feature is used (XDR/RDR bit is set). What exactly is draining feature and what it does?
Why do we initialize GPIO?
Since interrupt pin is connected via GPIO.
In other cases, where does the slave's interrupt pin gets connected?
If slave has an interrupt pin, you SHOULD initialize corresponding GPIO/IOMUX.
Some slave devices may not contain interrupt. In that case, no need to initialize any GPIO.
Summary:
You should initialize ALL GPIO/IOMUX for all input/output from processor to slave device.

Resources