

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Some concept of Embedded Real-Time System Programming are Anatomy, Cache Access Time, Instruction Formats, Instruction Formats, Instruction Formats, Multidimensional Meshes, Network Processors, Snooping Protocol. Main points of this lecture are: Netburner, Program, Simulate, Service Routine, Assembly Language, Something, Application, Interrupt, Switch, Wait
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


#include "predef.h" #include <stdio.h> #include <ctype.h> #include <startnet.h> #include <autoupdate.h> #include <dhcpclient.h> #include <../mod5282/system/sim5282.h> #include <cfinter.h>
/* An interrupt setup helper defined in bsp.c / extern "C" { / This function sets up the 5282 interrupt controller */ void SetIntc(int intc,long func, int vector, int level,int prio ); }
/* We are going to use a Semaphore to communicate between the IRQ1 pin ISR and the main application */ OS_SEM IrqPostSem;
/* Declare our interrupt procedure.... name: our_irq1_pin_isr masking level (The value of the ColdFire SR during the interrupt: use 0x2700 to mask all interrupts. 0x2500 to mask levels 1-5 etc... 0x2100 to mask level 1 / INTERRUPT(out_irq1_pin_isr, 0x2100 ) { / WARNING WARNING WARNING Only a very limited set of RTOS functions can be called from within an interrupt service routine. Basically, only OS POST functions and LED functions should be used No I/O (read, write or printf may be called), since they can block. */
sim.eport.epfr=0x02; /* Clear the interrupt edge 0 0 0 0 0 0 1 0 */ OSSemPost(&IrqPostSem); }
extern "C" { void UserMain(void * pd); void putdisp(unsigned short w); }
/* Helper function to display a decimal number */ void PutDispDecimal(WORD val, BOOL blank_zero ) {
WORD w;
w = (val / 1000) * 0x1000; if ((w == 0) && (blank_zero)) w = 0xF000; w += ((val / 100)% 10) * 0x0100; if (w == 0xF000) w = 0xFF00; w += ((val / 10)% 10) * 0x0010; if (w == 0xFF00) w = 0xFFF0; w += ((val )% 10) * 0x0001; putdisp(w); }
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-13 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