Interconnectivity
Page 14 of 22
Firmware Programming Guide for PDIUSBD12
Philips Semiconductors - Asia Product Innovation Centre
Visit
http://www.flexiusb.com
6. Main Loop
Once powered up, MCU will need to initialize all its ports, memory, timer, and interrupt service routine handler.
After that, MCU will reconnect USB, which involves setting the Soft_Connect register to ON. This procedure is
important because it ensures that D12 will not operate before MCU is ready to serve D12.
In the main loop routine, MCU will poll for any activity on the keyboard. If any one of the specific keys is
pressed, the handle key commands will execute the routine and then return to the main loop. This routine is
added for debugging purposes only. A 1mSec timer is programmed to activate the routine to check for any
button pressed on the evaluation board.
When the polling reaches the check Setup packet, it verifies the setup flag set previously by the interrupt service
routine. If the setup flag is set, it will dispatch a device request to the protocol layer for processing. The
flowchart above shows the main program executing on the foreground.
Main Loop
initialize Ports, Memory and Timer
Setup ISR and Program Interrupt Controller
Reconnect USB
Program Exit?
Keyboard Pressed?
Timer Signal?
Bus Reset?
Suspend Change?
Setup Packet?
Loop
Restore ISR vectors
Reset Interrupt Controller
End
Read Key Code
Handle Key Commands
No
Yes
Update Test LEDs and Check Test Keys
On Evaluation Board
Display Bus Reset Event Detected
Read Suspend State
Display Suspend Changed Event
Dispatch Device Request to
Protocol Layer for Processing
Yes
Yes
Yes
Yes
No
No
No
No
Yes
No