LPC1343 SYSTICK.

Enviado:
29 Jun 2012 12:06
por fabim
Pessoal, aos que ja usaram este ou algum que possui o hw de systick.
Eu li no um que ele gera tb de 10ms, e existe até auto cal.
Este systick não pode ser modificado ?
Na minha aplicação, é necessário que exista um tb de aferição de portas de 1mS. Eu ja estou utilizando os 4 timers, 2 de 16 e 2 de 32, para capture de velocidade de motores, e pwm de controle também.
Eu observei o exemplo, e como vou utilizar os timers para capture e pwm, não posso utiliza-los para gerar um systick de 1ms.
Bom, pode ou não mexer naquele hW dedicado para o systick, e alterar o dito para 1ms ?
Thanks to all.

Enviado:
29 Jun 2012 14:22
por RobL
Se não estou enganado, já usei um exemplo de piscar leds para o LPC1343, com o sistick para 1ms . O exemplo é da CodRed para o LPCXpresso.

Enviado:
29 Jun 2012 14:47
por RobL
Estou tentando colocar o código mas o servidor deu pau.
Achei aqui :
- Código: Selecionar todos
#include "LPC13xx.h" /* LPC13xx definitions */
#include "gpio.h"
#include <cr_section_macros.h>
#include <NXP/crp.h>
// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
// Time period to wait between toggling LED. 2000 msecs = 2 secs.
#define DELAY_LEN 2000
#define LED_PORT 0 // Port for led
#define LED_BIT 7 // Bit on port for led
#define LED_ON 1 // Level to set port to turn on led
#define LED_OFF 0 // Level to set port to turn off led
volatile uint32_t msTicks; /* counts 1ms timeTicks */
/*----------------------------------------------------------------------------
SysTick_Handler
*----------------------------------------------------------------------------*/
void SysTick_Handler(void) {
msTicks++; /* increment counter necessary in Delay() */
}
/*------------------------------------------------------------------------------
delays number of tick Systicks (happens every 1 ms)
*------------------------------------------------------------------------------*/
__INLINE static void Delay (uint32_t dlyTicks) {
uint32_t curTicks;
curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks);
}
/* Main Program */
int main (void) {
// Initialize GPIO (sets up clock)
GPIOInit();
// Set port 0_7 - LED2 on LPCXpresso board to output
GPIOSetDir( LED_PORT, LED_BIT, 1 );
if (SysTick_Config(SystemCoreClock / 1000)) { /* Setup SysTick Timer for 1 msec interrupts */
while (1); /* Capture error */
}
if ( !(SysTick->CTRL & SysTick_CTRL_CLKSOURCE_Msk) )
{
/* When external reference clock is used(CLKSOURCE in
Systick Control and register bit 2 is set to 0), the
SYSTICKCLKDIV must be a non-zero value and 2.5 times
faster than the reference clock.
When core clock, or system AHB clock, is used(CLKSOURCE
in Systick Control and register bit 2 is set to 1), the
SYSTICKCLKDIV has no effect to the SYSTICK frequency. See
more on Systick clock and status register in Cortex-M3
technical Reference Manual. */
LPC_SYSCON->SYSTICKCLKDIV = 0x08;
}
while (1) /* Loop forever */
{
// Turn LED on, then wait
GPIOSetValue( LED_PORT, LED_BIT, LED_ON );
Delay (DELAY_LEN);
// Turn LED off, then wait
GPIOSetValue( LED_PORT, LED_BIT, LED_OFF );
Delay (DELAY_LEN);
}
}