hello,
can I do multitasking in ARM LPC2148. I want to display on LCD, LED and 7segment at the same time.
is it possible?????
void GPIO8LED_show(void) { static BYTE GPIO8LED_on = 1; static BYTE GPIO8LED_i = 0; if ( ( timer_GPIO8LED == 0 ) && ( GPIO8LED_show_on ) ) { if (GPIO8LED_on) { IOSET1 = ~( LED8SET & ( 7 << (18+GPIO8LED_i) ) ); } else { IOCLR1 = LED8SET & ( 7 << (18+GPIO8LED_i) ); if ( GPIO8LED_i == 7 ) { GPIO8LED_i = 0; } else { GPIO8LED_i++; } } GPIO8LED_on = 1 - GPIO8LED_on; timer_GPIO8LED = 8; } } void MSPI_init(void) { //PINSEL0 = (PINSEL0 & 0xFFFF00FF) | 0x00005500; // Connect SPI PINSEL0 = (PINSEL0 & (~(0xFF << 8))) | (0x55 << 8) ; IODIR0 = HC595_CS; S0SPCCR = 0x52; // Set SPI Clock S0SPCR = (0 << 3) | // CPHA = 0, [del] (1 << 4) | // CPOL = 1, SCK [del] (1 << 5) | // MSTR = 1, SPI [del] (0 << 6) | // LSBF = 0, SPI [del] (0 << 7); // SPIE = 0, [del] } void MSPI7LED_show(void) { static BYTE MSPI7LED_i = 0; BYTE const HEX_TAB[16] = { // 0 1 2 3 4 5 6 7 8 9 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, // A b C d E F 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E }; if ( ( timer_MSPI7LED == 0 ) && ( MSPI7LED_show_on ) ) { IOCLR0 = HC595_CS; // 74HC595 SPI_SPDR = HEX_TAB[MSPI7LED_i]; while( 0 == (SPI_SPSR & 0x80) ); // Wait IOSET0 = HC595_CS; if ( MSPI7LED_i == 15 ) { MSPI7LED_i = 0; } else { MSPI7LED_i++; } timer_MSPI7LED = 95; } }
void Timer0Handler (void) __irq { timer_counter++; if ( timer_KEYpress != 0 ) timer_KEYpress--; else KEYS_check(); if ( timer_GPIO8LED != 0 ) timer_GPIO8LED--; if ( timer_MSPI7LED != 0 ) timer_MSPI7LED--; T0IR = 1; /* clear interrupt flag */ VICVectAddr = 0; /* Acknowledge Interrupt */ }
The above code which I posted, is a [low quality] demonstration for: A simple supervisory loop processing each module would almost certainly be sufficient.