Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External power control (PC13) is not set after power-on, only if enabling/disabling from model menu #446

Open
wimalopaan opened this issue Dec 12, 2024 · 22 comments
Labels
bug Something isn't working

Comments

@wimalopaan
Copy link

No description provided.

@ajjjjjjjj
Copy link
Member

Do you know what revision made regression and can you share your eeprom data because i can't reproduce?

@wimalopaan
Copy link
Author

I'm actually on 3eab877 and use this cmake line:

cmake -DCRSF_FULLDUPLEX=yes -DCRSF_EXTENDED_TYPES=ON -DUSB_MSD=OFF -DEXTPWR_INVERT=yes -DSBUS_TRAINER=OFF  -DUSB_SERIAL=OFF -DCMAKE_BUILD_TYPE=Release
-DSPLASH=OFF  -DTIMERS=1 -DHELI=OFF -DTRANSLATIONS=DE -DPCB=I6X -DLUA_COMPILER=NO -DLUA=NO -DGVARS=YES  -DMULTIMODULE=OFF -DOVERRIDE_CHANNEL_FUNCTION
=OFF -DPCBI6X_ELRS=YES ..

@wimalopaan
Copy link
Author

... and I made a full EEPROM reset, but that didn't solve the problem.

@wimalopaan
Copy link
Author

If the type of the ext. module is PPM, then the PC13 functions as expected. So, initializing the crsf-stuff the setting of this pin is missing. I tried to debug a bit, but could not localize the bug in a first attempt.

@ajjjjjjjj ajjjjjjjj added the bug Something isn't working label Dec 13, 2024
@wimalopaan
Copy link
Author

This is called if started with 'PPM' as ext module:

opentxInit
opentxStart(0)
setupPulses 0: 0->1
disable_no_pulses 0
intmoduleStop
init_no_pulses 0
intmoduleNoneStart
extmoduleTimerStart 18000 0
setupPulses 1: 0->2
disable_no_pulses 1
extmoduleStop
DisablePPsOut
init_ppm
extmodulePpmStart

This is called if started with 'CRSF'as ext module:

opentxInit
opentxStart(0)
setupPulses 1: 0->3
disable_no_pulses 1
extmoduleStop
DisablePPMOut
telemetryPortInit 400000
setupPulses 0: 0->1
disable_no_pulses 0
intmoduleStop
init_no_pulses 0
intmoduleNoneStart
extmoduleTimerStart 18000 0

In 'extmoduleTimerStart' the PC13 pin should be set if the 'state' argument is 'true', but that never happens.

@wimalopaan
Copy link
Author

wimalopaan commented Dec 14, 2024

Looks like the problem is here:

void init_no_pulses(uint32_t port) {
  TRACE("init_no_pulses %d", port);
  if (port == INTERNAL_MODULE) {
    intmoduleNoneStart();
  }
//   else {
    extmoduleTimerStart(18000, false);
//   }
}

Removing the comments seems to fix it.
Edit:
No does not: niw, if started with CRSF, it is not turned off from the menu.

The logic seems to be totally srewed.

@ajjjjjjjj
Copy link
Member

I remember this part, I was hoping to never touch it again 🙈

@wimalopaan
Copy link
Author

Looks like I having a problem with the EEProm.
Using an official build, the eeprom-save-caret does not vanisch after eeprom reset.

@ajjjjjjjj
Copy link
Member

Auto save is disabled when usb is connected - maybe this? This is standard OpenTX logic, but i don't know the reason behind it, maybe needs to be changed.

@wimalopaan
Copy link
Author

No USB used in my tests

@wimalopaan
Copy link
Author

Can you reproduce that with my cmake?

@ajjjjjjjj
Copy link
Member

I will take a look and try to solve module power in next few days

@wimalopaan
Copy link
Author

I added further debug messages, but this part looks like a total mess. I'm not able to get through ... It's difficult to debug because setupPulses() is called permanently.

@wimalopaan
Copy link
Author

No I get Unexpected Shutdown detected calling disable_no_pulses(port); and an exclamation mark in the upper right corner of the LCD.

@ajjjjjjjj
Copy link
Member

Whole part needs porting current opentx/edgetx solution or investigation if ppm setup is done correctly

@wimalopaan
Copy link
Author

Better to remove all the external PPM stuff. Who is using that anymore?

@ajjjjjjjj
Copy link
Member

And out of sudden someone just asked about PPM on discord...
But it definitely needs improvements, maybe it will be not that hard.
I don't like "simplification" where PPM IN uses same timer as ext module, when we have spare TIM2, which break module toggle logic in effect.

@wimalopaan
Copy link
Author

But it definitely needs improvements, maybe it will be not that hard.
I don't like "simplification" where PPM IN uses same timer as ext module, when we have spare TIM2, which break module toggle logic in effect.

It would be very cool, if you could donate some time on that topic.

@ajjjjjjjj
Copy link
Member

ajjjjjjjj commented Dec 16, 2024

I haven't tested that yet, but it seems that EXTMODULE_TIMER is configured in wrong place. Should be in extmodulePpmStart() and extmoduleTimerStart(), then logic with enabling else statement in init_no_pulses should not break anything.

@wimalopaan
Copy link
Author

I haven't tested that yet, but it seems that EXTMODULE_TIMER is configured in wrong place. Should be in extmodulePpmStart() and extmoduleTimerStart(), then logic with enabling else statement in init_no_pulses should not break anything.

I really hope you'll get through that mess ...

@ajjjjjjjj
Copy link
Member

I found it but it needs mayor refactorization of this true mess.
Issue is external module timer never starts for OFF or CRSF mode, but should be always running. Thats also why watchdog heartbeat was broken in the first place. So another mistery almost solved.

@wimalopaan
Copy link
Author

I found it but it needs mayor refactorization of this true mess.

Great!!!
I wasn't able to discover any logic in the flow of calls ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants