- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,everyone:
I have to output information by UART in my project, When program loaded from FLASH(EPCS),then CPU halt at fprintf(),so do with getc(),fscanf(),but not fwrite(). but it is ok in debug mode with JTAG-UART. Why? Who can help me,thanks!Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it'd be easier if you can post the code here..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
code as following:
int main() { FILE *fp; char echo; fp = fopen(UART_0_NAME, "r+"); if (fp) { while (1) { echo = getc(fp); fwrite(&echo, 1, 1, fp); fprintf(fp, ">>\r\n"); // always stop here } } return 0; }- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, the stdio functions will probably be buffering the output data until \n is output - so nothing will try to access the uart itself until then.
That probably means your uart either isn't configured properly (so the io cycles to it are stalling the cpu), or any interrupt service routine is misbehaving (looping or not clearing the IRQ line).- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the difference between using jtag debug and software run from flash? It confuses me.
Everything is ok when debug it, but it don't work when boot from flash. Why?God,help me,please!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Typically, when it's "running" from flash, it's really copying code from flash into RAM and then executing that code.
How do you know that your code stops at fprintf() when loading from EPCS/flash? Have you run a minimal memtest (with a simple DMA in your system) on the memory you're loading to? What is your offchip memory? Regards, slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i solved it finally!it is so easy when i got it.
Only set "Exception Vecoter" in CPU seting to SDRAM not EPCS_FLASH_CONTROLLER in SOPC Builder. If exception vector be pointed to epcs_flash_controller, then interrupt of fprintf() happened, it can't jump to the correct location. Thanks to normad, dsl and slacker.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page