View previous topic :: View next topic |
Author |
Message |
PrinceNai
Joined: 31 Oct 2016 Posts: 527 Location: Montenegro
|
|
Posted: Thu Feb 13, 2025 7:04 am |
|
|
Another small suggestion:
#define PREAMBLE_MIN_TIME 7 * TE //6
If the preamble is 7*TE long, don't go so narrow. The point here is simply to always miss the synch bits. 6.5, 6.8, ok. There will come a hot day and suddenly it won't work any more because you'll miss the preamble for two counts. And another batch of hair will be gone for good :-)
Last edited by PrinceNai on Thu Feb 13, 2025 8:36 am; edited 1 time in total |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Thu Feb 13, 2025 7:30 am |
|
|
OKEY thanks  |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Thu Feb 13, 2025 10:30 am |
|
|
Also always better to use a crystal and caps instead of the internal oscillator if you need accurate,precise timing.
This is kinda important in most(all) serial communications and 'extremes' in temperature, hot or cold. |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Thu Feb 13, 2025 10:32 am |
|
|
I trust pic mcu in this regard, it will not let you down.  |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Sat Feb 22, 2025 6:51 am |
|
|
@princenai I have a question that bothers me. This manchester decode code works in ext_ interrupt. Why doesn't it work in IOC_ interrupt? |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Sat Feb 22, 2025 7:44 am |
|
|
Perhaps you've not setup the IOC registers correctly ? |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Sat Feb 22, 2025 9:01 am |
|
|
I set it up. But is there a speed difference between IOC and EXT interrupts? |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Sat Feb 22, 2025 10:17 am |
|
|
According to the datasheet, page 369,table-30-4, test OS20, OS21...... no.
Both have minimum spec of 25ns
However they are NOT 'tested, carved in stone' numbers
pretty sure knowing what you're using the PIC for they are not 'different'.
So as to why it doesn't work, leads me to believe you've not setup IOC the same as EXT_INT is setup. |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Sat Feb 22, 2025 10:59 am |
|
|
Maybe it's an area I overlooked. When I tested the IOC interrupt, it works. But when I use Manchester decode, things change. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Sat Feb 22, 2025 4:08 pm |
|
|
Post your setup code for both versions...... |
|
 |
PrinceNai
Joined: 31 Oct 2016 Posts: 527 Location: Montenegro
|
|
Posted: Sat Feb 22, 2025 6:05 pm |
|
|
Quote: | Post your setup code for both versions...... |
Yes. With external interrupt the direction of change is set manually in code according to what you are looking for in any particular state. The way it was done will not work directly with IOC. As Mr. T said, maybe your setup of IOC pin isn't correct, meaning that something else changes on other pins and interrupt fires because of that.
As a start, I'd loose all parts of the code that deal with the direction of change (it won't affect IOC anyway, but code will be easier to read) and add a test in the first state to check if it was a 0 to 1 transition before proceeding to second state. Everything depends on that. If the first interrupt happens on a 1-0 transition nothing will work. Simple, close complete first state except break; in
if(input_state(pin_A1) == 1){
}
If yes, go to second state, if not, exit and wait for next interrupt.
Time it takes to reach interrupt shouldn't be a problem, signals are more than long enough to allow for anything. I mean, 640us. Time for a coffee at those instruction cycle speeds. |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Sat Feb 22, 2025 6:39 pm |
|
|
Thanks for your answers. I'll test your suggestions when I find time. |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Sun Feb 23, 2025 7:27 am |
|
|
I made an edit for the IOC interrupt, it doesn't work that way.(note ioc interrupt is working)
Last edited by bulut_01 on Mon Feb 24, 2025 1:47 pm; edited 1 time in total |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Mon Feb 24, 2025 2:15 am |
|
|
@princenai Why is the above code not working with ioc interrupt? |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Mon Feb 24, 2025 8:08 am |
|
|
One possible reason, though I can't test...
is that 1st line of the IOC handler you clear the interrupt.
that should allow more interrupts to happen within the handler, which could be bad
My understanding is that the compiler clears the interrupt when the handler is completed...... |
|
 |
|