- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to add a UART to a minimal resources system.
Stdin/out are used by JTAG Uart. Is there any way to utilise the standard UART using HAL if fopen and similar are unavailable? I'm quite happy to access the registers directly but attempts to read the status register location always return a value of 0. Do I have to do something to allow direct access to the registers? Many thanksLink Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have data cache on your NIOS you will have to declare the variables as volatile unless you use IORD_..........
Boris- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
volatile isn't enough. You need to use the alt_remap_uncached() function to directly access a register if you have cache. The IORD* macros are easier to use for that purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Making variables 'volatile' doesn't cause the data cache to be bypassed.
It is probably required [1] to ensure that all the memory transfers requested by the C source actually happen, and in the correct order. Passing -mno-cache-volatile to the compiler will cause it to use ldio/stio instructions for volatile data. But it would be more useful if this were a separate attribute. [1] judicious use of memory barriers [2] can have the desired effect. [2] eg asm volatile("\n":::"memory") tells gcc that any of memory might have changed - so it must not have memory cached in registers (and v.v.) across the statement.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you that helped me to understand things better.
/Boris- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many thanks for the ideas - using IORD and IOWR works fine.
As a matter of interest, where are functions such as these documented?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you should find them in the software developper's handbook, in the hal section (http://www.altera.com/literature/hb/nios2/n2sw_nii5v2_02.pdf).

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