- Posts: 45
Tx Reset when using Flysky protocol
- ColdFire
- Topic Author
- Offline
#define CS_LO() gpio_clear(GPIOA, GPIO13); \
usleep(1)
which seems to solve the problem for me. the delay time could be shorter though (have not tested that yet).
Please Log in or Create an account to join the conversation.
- domcars0
- Offline
- Posts: 390
Read his conversation with sbstnp here :
bitbucket.org/PhracturedBlue/deviation/i...sky-protocol-reboots
Devo 10 (+7e) owner. It's mine, please don't touch it with your big fingers
Please Log in or Create an account to join the conversation.
- ColdFire
- Topic Author
- Offline
- Posts: 45
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
I would like to know if it fixes your issue as well, or if I need to do something additional. That fix can't be released as is as it won't work for the devo7e, but hopeulfly with some more experimentation we can finde something that works everywhere
Please Log in or Create an account to join the conversation.
- ColdFire
- Topic Author
- Offline
- Posts: 45
The problem is on the come-and-go basis. sometime it resets Tx every time, other time the whole thing just run stable.
There is one time I narrowed down the problem to the change to some file (clock.c and syscalls.c). use older version of these two files with new revision will make the problem go away. though I never come up with an explanation for that.
yesterday I was applying some change to the source code and the trick does not work anymore , then I started to play with SPI_read function and found the adding of delay did the trick.
PhracturedBlue wrote: Please try the fix I proposed to sbstnp.
I would like to know if it fixes your issue as well, or if I need to do something additional. That fix can't be released as is as it won't work for the devo7e, but hopeulfly with some more experimentation we can finde something that works everywhere
Please Log in or Create an account to join the conversation.
- sbstnp
- Offline
- Posts: 649
ColdFire wrote: Not sure if the root cause has been identified. From what I understand it is more likely that the program get stucked in spi_read function, and I suspect that it is the CS line that causes the problem. so I add a little bit delay after pulling the CS line low:
#define CS_LO() gpio_clear(GPIOA, GPIO13); \
usleep(1)
which seems to solve the problem for me. the delay time could be shorter though (have not tested that yet).
This doesn't work on my Devo 10. Still get reboots.
Devo 10 + 4in1
FrSky Taranis + TBS Crossfire
Please Log in or Create an account to join the conversation.
- ColdFire
- Topic Author
- Offline
- Posts: 45
sbstnp wrote:
ColdFire wrote: Not sure if the root cause has been identified. From what I understand it is more likely that the program get stucked in spi_read function, and I suspect that it is the CS line that causes the problem. so I add a little bit delay after pulling the CS line low:
#define CS_LO() gpio_clear(GPIOA, GPIO13); \
usleep(1)
which seems to solve the problem for me. the delay time could be shorter though (have not tested that yet).
This doesn't work on my Devo 10. Still get reboots.
Please Log in or Create an account to join the conversation.
- ColdFire
- Topic Author
- Offline
- Posts: 45
Here comes another fix I have:
add 1us delay (after the spi_xfer) in A7105_ReadReg:
u8 A7105_ReadReg(u8 address)
{
u8 data;
int i;
CS_LO();
spi_xfer(SPI2, 0x40 | address);
usleep(1);
spi_disable(SPI2);
spi_set_bidirectional_receive_only_mode(SPI2);
spi_enable(SPI2);
for(i = 0; i < 10; i++)
;
spi_disable(SPI2);
data = spi_read(SPI2);
CS_HI();
spi_set_unidirectional_mode(SPI2);
spi_enable(SPI2);
return data;
}
It works fine for me so far. I also tried to reload the model for more than 20 times and it seems to be fairly stable. The delay after 7105 reset seems to be less strict in this case: either 10000us or 100000us works.
sbstnp wrote:
ColdFire wrote: Not sure if the root cause has been identified. From what I understand it is more likely that the program get stucked in spi_read function, and I suspect that it is the CS line that causes the problem. so I add a little bit delay after pulling the CS line low:
#define CS_LO() gpio_clear(GPIOA, GPIO13); \
usleep(1)
which seems to solve the problem for me. the delay time could be shorter though (have not tested that yet).
This doesn't work on my Devo 10. Still get reboots.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
I have checked in tweaked code which follows the Refernece Manual with respect to transmit and receive. It seems to work well for me, but I'd like everyone with issues to try the latest code and report back. If you get reboots, please provide the elf and errors.txt file. These are really helpful in letting me see what is going on.
Additionally I may not have been waiting long enough for the transmit to complete before shutdown, so I properly checked that too.
Please Log in or Create an account to join the conversation.
- sbstnp
- Offline
- Posts: 649
Devo 10 + 4in1
FrSky Taranis + TBS Crossfire
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Please Log in or Create an account to join the conversation.
- ColdFire
- Topic Author
- Offline
- Posts: 45
Great work!
PhracturedBlue wrote: I did a bunch of experimentation. Unfortunately my devo8 rarely locks up with the Flysky/hubsan protocols, but I was able to get some decent testing in. As Coldfilre speculated, the problem seems to be that spi_read hangs forever. I believe this is because the SPI read is never started (and thus never finishes). The STM32 has a rather odd interface to reading in 3-wire mode. you need to hold the spi enabled for more than 1 SPI clock and less than 8. The 'for()' loop was supposed to do that, but it is getting optimized out, so we aren't holding the enable long enough to guarantee that a read works.
I have checked in tweaked code which follows the Refernece Manual with respect to transmit and receive. It seems to work well for me, but I'd like everyone with issues to try the latest code and report back. If you get reboots, please provide the elf and errors.txt file. These are really helpful in letting me see what is going on.
Additionally I may not have been waiting long enough for the transmit to complete before shutdown, so I properly checked that too.
Please Log in or Create an account to join the conversation.
- Home
- Forum
- Development
- Development
- Tx Reset when using Flysky protocol