Discussion Forum

multitasking in ARM7

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
sandy k
Posted
19-Mar-2010 14:34 GMT
Toolset
ARM
New! multitasking in ARM7

hello,

can I do multitasking in ARM LPC2148.
I want to display on LCD, LED and 7segment at the same time.

is it possible?????

Read-Only
Author
Mike Kleshov
Posted
19-Mar-2010 15:07 GMT
Toolset
ARM
New! RE: multitasking in ARM7

is it possible?????

Yes, it is.

Read-Only
Author
Andy Neil
Posted
19-Mar-2010 15:25 GMT
Toolset
ARM
New! RE: is it possible?

Of course it's possible - even an 8051 can do it!

But it certainly isn't necessary just for what you've described!

Read-Only
Author
Marco Catellani
Posted
19-Mar-2010 17:55 GMT
Toolset
ARM
New! RE: is it possible?

Almost every microcontroller can do it.

Read-Only
Author
sandy k
Posted
21-Mar-2010 07:17 GMT
Toolset
ARM
New! RE: is it possible?

do I need to install some operating system like real time Linux???

I am working with LPC2148. In this project, I am displaying data on LCDs which is continuously changing. also I want to read input ports.

can it be done like operating system working??? one program for checking i/p ports and second to display data on LCDs. only one is executing for fixed time and after timeout storing its status on stack and second is executing for fixed time..

Read-Only
Author
Tamir Michael
Posted
21-Mar-2010 10:26 GMT
Toolset
ARM
New! RE: is it possible?

Search keil forum for "RTX". Also inspect your "Options for target...", Target page ("operating system").

Read-Only
Author
IB Shy
Posted
21-Mar-2010 11:14 GMT
Toolset
ARM
New! RE: is it possible?

As Andy has already mentioned, multitasking is not necessary for what you've described.

A simple supervisory loop processing each module would almost certainly be sufficient.

Read-Only
Author
John Linq
Posted
22-Mar-2010 02:56 GMT
Toolset
ARM
New! RE: is it possible?

I wrote this at 2008.Nov.04 =>

int main (void)
{
        char LFnCR[] = "\n\r";

    init_VIC();
    UARTInit(9600);     /* baud rate setting */
        init_timer();

        enable_timer(0);

        PINSEL2 = PINSEL2 & (~0x08);    // for GPIO 8LED
        IODIR1  = LED8SET;              // for GPIO 8LED

        MSPI_init();

    while (1)
    {                           /* Loop forever */

                GPIO8LED_show();

                MSPI7LED_show();

                UART0rbREAD();

                if (cmd_ready)
                {
                        UART0sbWRITE( (BYTE *)cmd_string, strlen((const char *)cmd_string) );
                        UART0sbWRITE( (BYTE *)LFnCR     , 2 );
                        UART0sendKICK();
                        memset( cmd_string, 0x00, 32 );
                        cmdstr_i = 0;
                        cmd_ready = 0;
                }

                KEYS_control();

    }
        // return 0;
}


void KEYS_check(void)
{
        IOPIN0_last = IOPIN0_this;
        IOPIN0_this = IOPIN0;

        IOPIN0_stat = IOPIN0_last ^ IOPIN0_this & IOPIN0_last;

        if ( ( IOPIN0_stat & KEY1 ) == KEY1 )
                KEY1_pressed = 1;

        if ( ( IOPIN0_stat & KEY2 ) == KEY2 )
                KEY2_pressed = 1;

        if ( ( IOPIN0_stat & KEY3 ) == KEY3 )
                KEY3_pressed = 1;

        if ( ( IOPIN0_stat & KEY4 ) == KEY4 )
                KEY4_pressed = 1;

        if ( ( IOPIN0_stat & KEY5 ) == KEY5 )
                KEY5_pressed = 1;

        if ( ( IOPIN0_stat & KEY6 ) == KEY6 )
                KEY6_pressed = 1;

        timer_KEYpress = 2;
}


void KEYS_control(void)
{
        static BYTE GPIO8LED_pos = 1;
        static BYTE MSPI7LED_pos = 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 ( KEY1_pressed == 1 )
        {
                GPIO8LED_show_on = 1 - GPIO8LED_show_on;
                KEY1_pressed = 0;
        }

        if ( KEY4_pressed == 1 )
        {
                MSPI7LED_show_on = 1 - MSPI7LED_show_on;
                KEY4_pressed = 0;
        }

        if ( GPIO8LED_show_on == 0 )
        {
                if ( KEY2_pressed == 1 )
                {
                        if ( GPIO8LED_pos > 1 )
                                GPIO8LED_pos--;
                        KEY2_pressed = 0;
                }
                if ( KEY3_pressed == 1 )
                {
                        if ( GPIO8LED_pos < 8 )
                                GPIO8LED_pos++;
                        KEY3_pressed = 0;
                }
                IOCLR1 =    1 << (17+GPIO8LED_pos)  ;
                IOSET1 = ~( 1 << (17+GPIO8LED_pos) );
        }

        if ( MSPI7LED_show_on == 0 )
        {
                if ( KEY5_pressed == 1 )
                {
                        if ( MSPI7LED_pos > 0 )
                                MSPI7LED_pos--;
                        KEY5_pressed = 0;
                }
                if ( KEY6_pressed == 1 )
                {
                        if ( MSPI7LED_pos < 15 )
                                MSPI7LED_pos++;
                        KEY6_pressed = 0;
                }
                IOCLR0 = HC595_CS;
                SPI_SPDR = HEX_TAB[MSPI7LED_pos];
                while( 0 == (SPI_SPSR & 0x80) );
                IOSET0 = HC595_CS;
        }
}



Read-Only
Author
John Linq
Posted
22-Mar-2010 03:01 GMT
Toolset
ARM
New! RE: 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;
        }
}
Read-Only
Author
John Linq
Posted
22-Mar-2010 03:17 GMT
Toolset
ARM
New! RE: is it possible?
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 */
}
Read-Only
Author
John Linq
Posted
22-Mar-2010 03:25 GMT
Toolset
ARM
New! RE: is it possible?

The above code which I posted, is a [low quality] demonstration for:
A simple supervisory loop processing each module would almost certainly be sufficient.

Next Thread | Thread List | Previous Thread Start a Thread | Settings