Saturday, 27 March 2010 03:30
M. Ganesh Raaja
// Start USB for 5V operation and wait till enumeration is complete USBFS_Start(0, USB_5V_OPERATION); while(!USBFS_bGetConfiguration());
// Load the IN endpoint with data with no toggle USBFS_LoadInEP(1, Data, 8, USB_NO_TOGGLE);
while(1) { ... // Other code ... // Wait till EP1 becomes free while(!USBFS_bGetEPAckState(1));
// Load EP1 with gamepad report USBFS_LoadInEP(1, Data, 8, USB_TOGGLE); }
Above code shows the general program flow when using an USBFS user module to send data to the PC using an IN Endpoint. If you notice, the USBFS_LoadInEP function call before the while loop uses “USB_NO_TOGGLE” and the call inside the while loop uses “USB_TOGGLE”. What is this TOGGLE and NO_TOGGLE? What is the significance of these constants? I can understand from the above code that the first time I call the USBFS_LoadInEP function, I have to use NO_TOGGLE option and TOGGLE for further transactions. Why is it so? These are some of the questions a first time user of USB faces.
Read more...
|
Monday, 01 March 2010 14:56
M. Ganesh Raaja
Many times in applications using the Watchdog timer, there may be a requirement to detect if a reset occurred due to Watchdog or POR / XRES and the application may either start fresh in case of POR / XRES or recover and start executing from the state when the watchdog reset occurred.
DETECT THE SOURCE OF RESET
The first requirement is to find out the source of reset. This can be done by checking the WDRS bit in the CPU_SCR0 register. This bit is set in case of a watchdog reset event. The below code in the beginning of main.c can be used.
if(CPU_SCR0 & CPU_SCR0_WDRS_MASK) { // Reset is due to Watchdog }
PRESERVE GLOBAL VARIABLES
In order to recover from a watchdog reset and resume the application, it is necessary that the Global variables be preserved when the watchdog reset occurs. This can be done by setting the IRAMDIS bit in the CPU_SCR1 register. When this bit is set, all the cells marked “??” in the below table are preserved during a Watchdog reset (taken from Technical Reference Manual Section 3).
Read more...
Friday, 08 January 2010 15:22
Madhan Kumar K
In a micro controller like PSoC 1 where the maximum Flash size is 32K, code optimization plays a very important role in creating compact code that fits the small flash size of the device. Following are some of the optimization techniques that can be used on PSoC1 projects with the ImageCraft compiler.
Relocatable start code address
This is the address from where the compiler starts placing relocatable code. It has to be set to a value after the end of boot.asm code. The optimal ‘Relocatable start code address’ is right after the end of boot.asm code. When this address is greater than what it needs to be,
Read more...
|
|
|
|
|
|
Page 1 of 3 |