Docsity

NetBurner Microcontroller Interrupts Lab Exercises, Exercises of Computer Programming

Toggle sidebar
bg1
Lab exercise 4:
1) Run the NetBurner Mod5282 Interrupts Application Note’s example program that services interrupts from the IRQ switch.
2) Write a program that uses the IRQ switch in a different way. For example, you might use the LED’s to simulate a ball
moving. An interrupt generated by the IRQ switch could make it change direction, or ? Use some assembly language in
your program, perhaps in the service routine.
NetBurner Mod5282 Interrupts Application Note’s example program:
void UserMain(void * pd)
{
InitializeStack();
if (EthernetIP==0)GetDHCPAddress();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
DWORD isr_count=0; /* Count how many times the switch was hit */
/* Initialize the semaphore we are using */
OSSemInit(&IrqPostSem,0);
/* First set up the Eport module to use IRQ1 as a falling-edge active IRQ pin
(See the 5282 UM chapter 11).
Set the pin assignment register irq1 pin falling edge sensitive.
*/
sim.eport.eppar=0x0008; /* 00 00 00 00 00 00 10 00 see table 11-3 in UM */
sim.eport.epddr=0x0; /* All edge port pins as inputs */
sim.eport.epier = 0x0002; /* Enable IRQ1 only 0 0 0 0 0 0 1 0 */
/* Now enable the actual interrupt controller. See users manual chapter 10 for
more information. We are going to use the BSP helper function declared above
and implemented in BSP.c
*/
SetIntc(0, /* The first interrupt controller */
(long)&out_irq1_pin_isr, /* Our interrupt function */
1, /* The vector number from the users manual table 10-13 */
1, /* Set this to priority 1 but any value from 1 to 6 would
be valid.*/
1 /* The priority within the gross levels; see chapter 10, any
value from 0 to 7 is ok */
);
iprintf("Application started\n");
iprintf("Press the IRQ button on the development board.\n");
while (1)
{
OSSemPend(&IrqPostSem,0 /* Wait forever */);
PutDispDecimal(++isr_count,true);
iprintf("The interrupt Switch was hit %ld times\r\n", isr_count);
}
}
Docsity.com
pf2

Partial preview of the text

Download NetBurner Microcontroller Interrupts Lab Exercises and more Exercises Computer Programming in PDF only on Docsity!

Lab exercise 4:

1) Run the NetBurner Mod5282 Interrupts Application Note’s example program that services interrupts from the IRQ switch.

2) Write a program that uses the IRQ switch in a different way. For example, you might use the LED’s to simulate a ball

moving. An interrupt generated by the IRQ switch could make it change direction, or? Use some assembly language in

your program, perhaps in the service routine.

NetBurner Mod5282 Interrupts Application Note’s example program:

void UserMain(void * pd) { InitializeStack(); if (EthernetIP==0)GetDHCPAddress(); OSChangePrio(MAIN_PRIO); EnableAutoUpdate(); DWORD isr_count=0; /* Count how many times the switch was hit / / Initialize the semaphore we are using / OSSemInit(&IrqPostSem,0); / First set up the Eport module to use IRQ1 as a falling-edge active IRQ pin (See the 5282 UM chapter 11). Set the pin assignment register irq1 pin falling edge sensitive. / sim.eport.eppar=0x0008; / 00 00 00 00 00 00 10 00 see table 11-3 in UM / sim.eport.epddr=0x0; / All edge port pins as inputs / sim.eport.epier = 0x0002; / Enable IRQ1 only 0 0 0 0 0 0 1 0 / / Now enable the actual interrupt controller. See users manual chapter 10 for more information. We are going to use the BSP helper function declared above and implemented in BSP.c / SetIntc(0, / The first interrupt controller / (long)&out_irq1_pin_isr, / Our interrupt function / 1, / The vector number from the users manual table 10-13 / 1, / Set this to priority 1 but any value from 1 to 6 would be valid./ 1 / The priority within the gross levels; see chapter 10, any value from 0 to 7 is ok / ); iprintf("Application started\n"); iprintf("Press the IRQ button on the development board.\n"); while (1) { OSSemPend(&IrqPostSem,0 / Wait forever */); PutDispDecimal(++isr_count,true); iprintf("The interrupt Switch was hit %ld times\r\n", isr_count); } }

Docsity.com

Lab exercise 5:

1) Create an interrupt driven application in which two devices on the NetBurner Board generate interrupts. They could be a

timer, the A/D converter, and/or a Universal Asynchronous Receiver / Transmitter (UART). Be creative. Be prepared to

demonstrate your design June 1st.

Docsity.com