Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

UCD3138: UCD3138 Swith form user mode to Supervisor Mode

$
0
0

Part Number:UCD3138

Dear Sir/Ms.

Let me try to talk in words. My English is not very good. If you don't understand what I said please feel free and let me know.

I would like copy a segment plash data to the other plash address. for example from 0x2000 to 0x6000. I only can write 4 byte from start address. I found My UCD3138 reset. I write I GPIO high low pulse in UCD3138 first run from boot. 

16.1.10 description if not success ,UCD3138 will reset.

  My code write as following 


//
// ------------------------------------------------------------------ Functions
//

/*++

Routine Description:
    這程式用來寫入Pflash的資料

Arguments:
   
    Uint32 address - 寫入位址
    Uint32 data - 寫入資料

Return Value:

    None.

--*/
inline void int_prog_flash_word(Uint32 address, Uint32 data)
{
	*((volatile Uint32 *) address) = data; //write data to flash

	while(DecRegs.PFLASHCTRL.bit.BUSY != 0)
	{
		;//do nothing while it programs
	}
}

/*++

Routine Description:
    This function writes 64 bytes(converted from 128 characters) of data received from UART to PFlash

Arguments:

    Uint32 addr -

    Uint32 data_legth -

    Uint32 boot_flash_size -

Return Value:

    None.

--*/
inline void int_boot_handle_d7(Uint32 addr, Uint32 data_legth, Uint32 boot_flash_size)
{
	int i;
	Uint32 data;

	register FUNC_PTR1 func_ptr;
	func_ptr=(FUNC_PTR1)func_swap_area1;   


	if(addr==boot_flash_size)									// start from boot_flash, bootflash size = 1024*8, if comment for intial -kami comment
	{
		register Uint32 * program_index = (Uint32 *)func_swap_area1; //store destination address for program
		register Uint32 * source_index =  (Uint32 *)int_prog_flash_word; //Set source address of PFLASH;
		register Uint32 counter;
		for(counter=0; counter <20; counter++) //Copy program from PFLASH to RAM
		{
			*(program_index++)=*(source_index++);
		}
	}

	for(i=3;i<(data_legth-1);i=(i+4))  //does not have to write last byte of uart_rx_buf
	{	
		data=0;//(uart_rx_buf[i]<<24)+(uart_rx_buf[i+1]<<16)+(uart_rx_buf[i+2]<<8)+uart_rx_buf[i+3];
		DecRegs.MFBALR1.bit.RONLY = 0;
		DecRegs.FLASHILOCK.all = 0x42DC157E;// Write key to Program Flash Interlock Register
		
		func_ptr(addr,data);

		addr=addr+4;
	}
	return;
}

// add case 15 in software interrupt (SWI)

	case 15:
		int_boot_handle_d7(1024*24, 0x10, 1024*24);
			return;

// call case 15  write_plash in main loop.


		if((MiscAnalogRegs.GLBIOREAD.bit.FAULT0_IO_READ==0) && (flash_update_done==0))
		{
		 disable_interrupt();
		 write_pflash();
		 enable_interrupt();
		 flash_update_done=1;
		}

My Question is How to switch form user mode to supervisor mode? 


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>