реклама на сайте
подробности

 
 
> Изучение ARM, не моргает светодиод
mempfis_
сообщение Oct 12 2008, 20:23
Сообщение #1


Профессионал
*****

Группа: Свой
Сообщений: 1 001
Регистрация: 27-06-06
Пользователь №: 18 409



Добрый вечерsmile.gif
Прошу помощи у ARMщиков
Скачал с олимекса иаровский проект моргания светодиодом и пробую переделать под свою плату с lpc2468. Всё воскресенье бъюсь но никак заставить его моргать не могу sad.gif
Даже не знаю в каком направлении копать. Взял пример инициализации МК из проэкта (там настраивается PLL и выводы), настраиаю пин на вывод и дальше в цикле светодиод должен моргать. В симуляторе всё работает, а в железе нетsad.gif
Ниже привожу код а в аттачменте сам проэкт (IAR 5.20EV).
Подскажите чего там не хватает?

Код
/* *********************************************************
               Function declarations
  ********************************************************* */

/**********************************************************
                  Header files
**********************************************************/
#include "LPC23xx.h"
#include "target.h"
#include "target.c"
#include "macroses.h"

// LED1 (MCIPWR on Olimex LPC-2378-STK has an indicator LED)

/**********************************************************
                       MAIN
**********************************************************/

int    main (void) {
    
    //    
    TargetResetInit();
  
    // set io pins for led P0.21
    IODIR0 |= 0x00200000;    // pin P0.21 is an output, everything else is input after reset
    
    IOSET0 =  0x00200000;    // led off
    
    IOCLR0 =  0x00200000;    // led on
    
    
    // endless loop to toggle the red  LED P0.21
    while (1)
    {

            
            {
                            SET_LED();
                            for(unsigned long i=0; i<2000000; i++);
                            
                            CLR_LED();
                            for(unsigned long i=0; i<2000000; i++);
            }
    }
}


Код
#include "LPC23xx.h"
#include "type.h"
#include "irq.h"
#include "target.h"

/******************************************************************************
** Function name:        TargetInit
**
** Descriptions:        Initialize the target board; it is called in a necessary
**                        place, change it as needed
**
** parameters:            None
** Returned value:        None
**
******************************************************************************/
void TargetInit(void)
{
    /* Add your codes here */
    return;
}

/******************************************************************************
** Function name:        GPIOResetInit
**
** Descriptions:        Initialize the target board before running the main()
**                function; User may change it as needed, but may not
**                deleted it.
**
** parameters:            None
** Returned value:        None
**
******************************************************************************/
// void GPIOResetInit( void ) - mthomas, add static, avoid missing proto warning
static void GPIOResetInit( void )
{
    /* Reset all GPIO pins to default: primary function */
    PINSEL0 = 0x00000000;
    PINSEL1 = 0x00000000;
    PINSEL2 = 0x00000000;
    PINSEL3 = 0x00000000;
    PINSEL4 = 0x00000000;
    PINSEL5 = 0x00000000;
    PINSEL6 = 0x00000000;
    PINSEL7 = 0x00000000;
    PINSEL8 = 0x00000000;
    PINSEL9 = 0x00000000;
    PINSEL10 = 0x00000000;
    
    IODIR0 = 0x00000000;
    IODIR1 = 0x00000000;
    IOSET0 = 0x00000000;
    IOSET1 = 0x00000000;
    
    FIO0DIR = 0x00000000;
    FIO1DIR = 0x00000000;
    FIO2DIR = 0x00000000;
    FIO3DIR = 0x00000000;
    FIO4DIR = 0x00000000;
    
    FIO0SET = 0x00000000;
    FIO1SET = 0x00000000;
    FIO2SET = 0x00000000;
    FIO3SET = 0x00000000;
    FIO4SET = 0x00000000;
    return;        
}

/******************************************************************************
** Function name:        ConfigurePLL
**
** Descriptions:        Configure PLL switching to main OSC instead of IRC
**                        at power up and wake up from power down.
**                        This routine is used in TargetResetInit() and those
**                        examples using power down and wake up such as
**                        USB suspend to resume, ethernet WOL, and power management
**                        example
** parameters:            None
** Returned value:        None
**
******************************************************************************/
void ConfigurePLL ( void )
{
    DWORD MValue, NValue;

    if ( PLLSTAT & (1 << 25) )
    {
        PLLCON = 1;            /* Enable PLL, disconnected */
        PLLFEED = 0xaa;
        PLLFEED = 0x55;
    }

    PLLCON = 0;                /* Disable PLL, disconnected */
    PLLFEED = 0xaa;
    PLLFEED = 0x55;
    
    SCS |= 0x20;            /* Enable main OSC */
    while( !(SCS & 0x40) );    /* Wait until main OSC is usable */

    CLKSRCSEL = 0x1;        /* select main OSC, 12MHz, as the PLL clock source */

    PLLCFG = PLL_MValue | (PLL_NValue << 16);
    PLLFEED = 0xaa;
    PLLFEED = 0x55;
      
    PLLCON = 1;                /* Enable PLL, disconnected */
    PLLFEED = 0xaa;
    PLLFEED = 0x55;

    CCLKCFG = CCLKDivValue;    /* Set clock divider */
#if USE_USB
    USBCLKCFG = USBCLKDivValue;        /* usbclk = 288 MHz/6 = 48 MHz */
#endif

    while ( ((PLLSTAT & (1 << 26)) == 0) );    /* Check lock bit status */
    
    MValue = PLLSTAT & 0x00007FFF;
    NValue = (PLLSTAT & 0x00FF0000) >> 16;
    while ((MValue != PLL_MValue) && ( NValue != PLL_NValue) );

    PLLCON = 3;                /* enable and connect */
    PLLFEED = 0xaa;
    PLLFEED = 0x55;
    while ( ((PLLSTAT & (1 << 25)) == 0) );    /* Check connect bit status */
    return;
}

/******************************************************************************
** Function name:        TargetResetInit
**
** Descriptions:        Initialize the target board before running the main()
**                        function; User may change it as needed, but may not
**                        deleted it.
**
** parameters:            None
** Returned value:        None
**
******************************************************************************/
void TargetResetInit(void)
{

// mthomas
#if 0
#ifdef __DEBUG_RAM    
    MEMMAP = 0x2;            /* remap to internal RAM */
#endif

#ifdef __DEBUG_FLASH    
    MEMMAP = 0x1;            /* remap to internal flash */
#endif
#endif

#ifdef __DEBUG_RAM    
    MEMMAP = 0x2;            /* remap to internal RAM */
#else
    MEMMAP = 0x1;            /* remap to internal flash */
#endif


#if USE_USB
    PCONP |= 0x80000000;        /* Turn On USB PCLK */
#endif
    /* Configure PLL, switch from IRC to Main OSC */
    ConfigurePLL();

  /* Set system timers for each component */
#if (Fpclk / (Fcclk / 4)) == 1
    PCLKSEL0 = 0x00000000;    /* PCLK is 1/4 CCLK */
    PCLKSEL1 = 0x00000000;
#endif
#if (Fpclk / (Fcclk / 4)) == 2
    PCLKSEL0 = 0xAAAAAAAA;    /* PCLK is 1/2 CCLK */
    PCLKSEL1 = 0xAAAAAAAA;    
#endif
#if (Fpclk / (Fcclk / 4)) == 4
    PCLKSEL0 = 0x55555555;    /* PCLK is the same as CCLK */
    PCLKSEL1 = 0x55555555;    
#endif

    /* Set memory accelerater module*/
    MAMCR = 0;
#if Fcclk < 20000000
    MAMTIM = 1;
#else
#if Fcclk < 40000000
    MAMTIM = 2;
#else
    MAMTIM = 3;
#endif
#endif
    MAMCR = 2;

    GPIOResetInit();

    //init_VIC(); //malka proba!!!!
    return;
}

/******************************************************************************
**                            End Of File
******************************************************************************/
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 18th July 2025 - 18:00
Рейтинг@Mail.ru


Страница сгенерированна за 0.01372 секунд с 7
ELECTRONIX ©2004-2016