LPC1227- Extern Counter Mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC1227- Extern Counter Mode

575 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by saud_c on Fri Jul 25 00:49:31 MST 2014
Hey guys.

I want to use a extern counter and then toggle a output. The idea behind it is using the lpc1227 in counter mode for a extern PLL.
Since the lpc1227 is way cheaper than the HEF4059 and has a bigger frequency width, I think that this is a great way of solving this problem. The idea is in using the counter with the CAP0 (PIO0_1) to count with the rising_edge to MR3 then toggle MAT0. Does anyone have any ideas?
Unfortunately it does not work. This is my code:


Original Attachment has been moved to: counter_extern.c.zip

0 项奖励
回复
2 回复数

495 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by saud_c on Fri Jul 25 00:50:10 MST 2014

Quote: saud_c
Hey guys.

I want to use a extern counter and then toggle a output. The idea behind it is using the lpc1227 in counter mode for a extern PLL.
Since the lpc1227 is way cheaper than the HEF4059 and has a bigger frequency width, I think that this is a great way of solving this problem. The idea is in using the counter with the CAP0 (PIO0_1) to count with the rising_edge to MR3 then toggle MAT0. Does anyone have any ideas?
Unfortunately it does not work. This is my code

#ifdef __USE_CMSIS
#include "LPC12xx.h"
#endif

#include <cr_section_macros.h>

unsigned int i, k;


void TIMER16_0_IRQHandler(void)
{

LPC_CT16B0->IR= 1 <<3;                          //this is just for security, so that the Interrupt will be enabled
}

void timer16_init(void)
{
LPC_SYSCON->SYSAHBCLKCTRL |= 1<<7;

LPC_IOCON->PIO0_28 = 0x04;    // use PIO0_28 as MAT output
LPC_IOCON->PIO0_1 = 0x03;    // use PIO0_1 as CAP input
LPC_CT16B0->TCR = 1;    // activates counter mode
LPC_CT16B0->TC = 0;    // sets Timer Counter on 0
LPC_CT16B0->MCR = 3 <<9;    // activates MR3
LPC_CT16B0->MR3 = 100;    // sets MR3 value on 100, if TC= MR3
                                                                            // then interrupt
LPC_CT16B0->EMR = 0x31;    // toggle & activate MR0
LPC_CT16B0->CTCR = 0x1;    // enables Counter Mode, (CAP0 is the default
                                            // value)
LPC_CT16B0->IR = 1 <<3;    // enable Interrupt on MR3
NVIC_EnableIRQ(TIMER_16_0_IRQn);
}

int main(void) {

timer16_init();
    while(1) {
    }
}

0 项奖励
回复

495 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by saud_c on Fri Jul 25 00:52:24 MST 2014
[img=1000x10000]C:\Users\Saud\Desktop\counter_extern.PNG[/img]Hey guys.

I want to use a extern counter and then toggle a output. The idea behind it is using the lpc1227 in counter mode for a extern PLL.
Since the lpc1227 is way cheaper than the HEF4059 and has a bigger frequency width, I think that this is a great way of solving this problem. The idea is in using the counter with the CAP0 (PIO0_1) to count with the rising_edge to MR3 then toggle MAT0. Does anyone have any ideas?
Unfortunately it does not work. This is my code


0 项奖励
回复