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

Freeze when erasing page and receiving serial data #109

Closed
Gregwar opened this issue Mar 10, 2015 · 7 comments
Closed

Freeze when erasing page and receiving serial data #109

Gregwar opened this issue Mar 10, 2015 · 7 comments

Comments

@Gregwar
Copy link
Contributor

Gregwar commented Mar 10, 2015

Hello,

I'm working on an application where I need to change the flash. So, I erase pages and write bytes on-the-fly.

This is the erase page part:

FLASH_BASE->CR |= FLASH_CR_PER;
while (FLASH_BASE->SR & FLASH_SR_BSY);

FLASH_BASE->AR = pageAddr;
FLASH_BASE->CR |= FLASH_CR_STRT;
while (FLASH_BASE->SR & FLASH_SR_BSY);
FLASH_BASE->CR &= ~FLASH_CR_PER;

return true;

When there is serial data incoming in the same time, this results in a complete freeze of the chip just after starting the erasing.

Any idea why?

@Gregwar
Copy link
Contributor Author

Gregwar commented Mar 11, 2015

Looks like the uC doesn't freeze if I disable uarts before doing my operations and enable it again just after
I understand that a flash operation would stall the uC for like 20ms anyway, making me loose bytes on the uart. But I don't understand why it hangs forever.

@mbolivar
Copy link
Contributor

I have no idea. Perhaps bus contention oddness?

What happens if you put nop or WFI in the loop instead of a hard spin? (Unless you've turned it off, SysTick will wake you up if you go WFI).

@Gregwar
Copy link
Contributor Author

Gregwar commented Mar 11, 2015

I've tried a lot of things, and it looks like there is a relation with the usart handling
One of the possibilities is that thr usart interrupt occur at some point for another reason than rx data
Looks like checking the RXNE bit in the SR usart registers before appending data to the rb prevents hanging

@mbolivar
Copy link
Contributor

e1314f6 just got merged, which might fix that. Can you try with today's master?

@Gregwar
Copy link
Contributor Author

Gregwar commented Mar 11, 2015

Actually, this is what I did
I've also moved the uart interruption to the ram section

@mbolivar
Copy link
Contributor

OK, so is today's master working for you? I'll close if so.

@Gregwar
Copy link
Contributor Author

Gregwar commented Mar 11, 2015

Yes, I confirm it's ok

@Gregwar Gregwar closed this as completed Mar 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants