• 0

PS_UART_INTERRUPT ZYNQ 7000 ARM A9 _XSCUGIC


Question

Hello,

 

Currently, I am working with the uart_interrupt example for PS UART 1 using freertos running on core0 for Zybo z7-10. The example template works fine but I wish to change the priority mask threshold of the scugic. I am also not sure if I am doing this right! With some work, I found that the Interrupt Priority Mask Register (ICCPMR) is used to set a priority mask threshold and in Zynq ARM-A9 this register is located at 0xF8F0 0104.
Tracing down the code files associated with BSP, I found that during CPU Initialize a value of 0xF0 is written into this register. (8-bit priority mask value)
However, I cannot make any changes to these code files generated from BSP. And now I am not sure how to proceed with this!
I also read a descriptive explanation regarding this register as well as other registers related to interrupt in section 4.1 and 4.2 in the arm 9 GICmanual from http://reds.heig-vd.ch/share/cours/SoCF/gic_altera_manual_short.pdf

The explanation makes perfect sense when I search those respective registers in xscugic.c but I cannot change the code files. 

My end goal is to change the priority mask threshold so that I can try different values for the threshold and see how the UART interrupt signal behaves as based on the threshold there will times when UART interrupt will be disregarded/considered.

gic.png

Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi @fpga_123,

It looks like you are working on changing the correct file, presuming the xsugic.c you have up is in the file path 'interrupt_psuart_bsp->ps7_cortexa9_0->libsrc->scugic_v4_0->xscugic.c'. One thing that you will need to make sure of is that you do not regenerate the BSP sources otherwise, the changes you made will be overwritten.

It's also possible to change this in the IP library files themselves, but I would not recommend this as this would change it for every new project created, which I doubt you want to be the case.

Let me know if you have any other questions.

Thanks,
JColvin

Link to post
Share on other sites
  • 0
22 minutes ago, JColvin said:

Hi @fpga_123,

It looks like you are working on changing the correct file, presuming the xsugic.c you have up is in the file path 'interrupt_psuart_bsp->ps7_cortexa9_0->libsrc->scugic_v4_0->xscugic.c'. One thing that you will need to make sure of is that you do not regenerate the BSP sources otherwise, the changes you made will be overwritten.

It's also possible to change this in the IP library files themselves, but I would not recommend this as this would change it for every new project created, which I doubt you want to be the case.

Let me know if you have any other questions.

Thanks,
JColvin

Can you please elaborate about what you mean by changing it in the IP library files itself? How can I do that?

 

Thanks,

Link to post
Share on other sites
  • 0

This would be changing the source files themselves that Vitis/SDK pulls from. In a 2020.2 installation for example, the xscugic.c file could be found at:

D:\Xilinx\Vivado\2020.2\data\embeddedsw\XilinxProcessorIPLib\drivers\scugic_v4_2\src\xscugic.c

However, this is not recommended as you are effectively editing the source code, which can go badly if you are not careful. If you build this project on any other computer, the source file would need to be changed there as well, and you would need to remember that this change was made for every new project that you build, so your default behavior will not match what other users experience. That being said, there isn't anything stopping you from making the change in this file.

Thanks,
JColvin

Link to post
Share on other sites
  • 0

Does the fact that you are using FreeRTOS lock you out from changing the priority mask by normal means? For example, in a bare-metal application, when you configure your GIC you can just add the following code to change the mask:

uint32_t reg_data;

reg_data = 	XScuGic_CPUReadReg(p_XScuGicInst, XSCUGIC_CPU_PRIOR_OFFSET);
printf("\r\nXSCUGIC_CPU_PRIOR_OFFSET = 0x%08x\r\n", reg_data);

XScuGic_CPUWriteReg(p_XScuGicInst, XSCUGIC_CPU_PRIOR_OFFSET, 0xD0);

reg_data = 	XScuGic_CPUReadReg(p_XScuGicInst, XSCUGIC_CPU_PRIOR_OFFSET);
printf("XSCUGIC_CPU_PRIOR_OFFSET = 0x%08x\r\n\r\n", reg_data);

(The printf statements above are not required in final code, just used to show that the change works.)

So in FreeRTOS, after your system comes up, and before your tasks start running, see if you can change the mask using XScuGic_CPUWriteReg(inst_ptr, XSCUGIC_CPU_PRIOR_OFFSET, new_val).

 

Edited by DerekM
Link to post
Share on other sites
  • 0

I am of course missing the point that you don't have easy access to the SCUGIC instance pointer. So instead, try to change the priority mask directly using Xil_Out32(). I had a quick look at this in FreeRTOS, and I think it is working (unless something else changes it later in the background.)

printf("\r\nXSCUGIC_CPU_PRIOR_OFFSET = 0x%08x\r\n",  Xil_In32(0xF8F00104) );

Xil_Out32(0xF8F00104, 0xE0);

printf("XSCUGIC_CPU_PRIOR_OFFSET = 0x%08x\r\n\r\n",  Xil_In32(0xF8F00104) );


// FreeRTOS code:

xTimerStart( xTimer, 0 );

/* Start the tasks and timer running. */
vTaskStartScheduler();

 

Link to post
Share on other sites
  • 0

I don't think the above is going to work either. Every time a task runs, the mask gets set to 0xF8.

Edit to add: What you're trying to do is difficult because the OS will often change settings in the background. Surely there must be a way to do what you want using the FreeRTOS API?

Edited by DerekM
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now