EmbeddedRelated.com
Forums
Memfault Beyond the Launch

clock on a GPIO, lpc2387

Started by franciscocantero1 November 19, 2010
Hello,

I just join the group, how is everybody doing?
over this week I try to get some code working with IAR, the project is nearly working, but I need to talk to a chip with an input of 27 MHz and send data at 6.9Mbps.

I would like to know how to get a one of the GPIO pins to be a clock of 27MHz. My crystal is 12MHz. I thought of different ways of doing this:

1- do a PWM, but I dont know what kind of control I will have for being able to send some data in other line with 3 and 4 clock cycles of the 27MHz.

2- change the PLL setings to get a multiple of 27MHz, calculations where:
M=9
N=1

3- Do a counter and in the interrupt just toggle an output pin.

This is the first time that I program an arm processor, I read the manual, but the section for timers doesnt specify if i can bring a clock out.

Any help will be much apreciated.

Thanks

An Engineer's Guide to the LPC2100 Series

Hi,

You could use one of MATx pins with Timerx peripheral (choice 1). It's better
since you don't have to handle the interrupt. Hence, you got more MIPS to handle
your firmware. But to get exact 27Mhz, you need to modify your running clock
(PLL settings + dividers) (choice 2), so it'll run at integer multiple of 27Mhz.

Here's some illustration of the LPCxxxx Timer peripheral (with matched registers
name in orange):

Hope that helps

Regards,
-daniel

----- Original Message ----
From: franciscocantero1
To: l...
Sent: Sat, November 20, 2010 1:42:46 AM
Subject: [lpc2000] clock on a GPIO, lpc2387

Hello,

I just join the group, how is everybody doing?
over this week I try to get some code working with IAR, the project is nearly
working, but I need to talk to a chip with an input of 27 MHz and send data at
6.9Mbps.

I would like to know how to get a one of the GPIO pins to be a clock of 27MHz.
My crystal is 12MHz. I thought of different ways of doing this:

1- do a PWM, but I dont know what kind of control I will have for being able to
send some data in other line with 3 and 4 clock cycles of the 27MHz.

2- change the PLL setings to get a multiple of 27MHz, calculations where:
M=9
N=1

3- Do a counter and in the interrupt just toggle an output pin.

This is the first time that I program an arm processor, I read the manual, but
the section for timers doesnt specify if i can bring a clock out.

Any help will be much apreciated.

Thanks
Hi,

You have a device that takes clocked data?
Most devices like that won't require exactly 27MHz and likely this is what the SPI/SSP is made for.

--- In l..., "franciscocantero1" wrote:
>
> Hello,
>
> I just join the group, how is everybody doing?
> over this week I try to get some code working with IAR, the project is nearly working, but I need to talk to a chip with an input of 27 MHz and send data at 6.9Mbps.
>
> I would like to know how to get a one of the GPIO pins to be a clock of 27MHz. My crystal is 12MHz. I thought of different ways of doing this:
>
> 1- do a PWM, but I dont know what kind of control I will have for being able to send some data in other line with 3 and 4 clock cycles of the 27MHz.
>
> 2- change the PLL setings to get a multiple of 27MHz, calculations where:
> M=9
> N=1
>
> 3- Do a counter and in the interrupt just toggle an output pin.
>
> This is the first time that I program an arm processor, I read the manual, but the section for timers doesnt specify if i can bring a clock out.
>
> Any help will be much apreciated.
>
> Thanks
>

Hi,

I had the wrong set up for the PLL, at the moment I can only get it to work with:
M
N=0
clksrcsel=1
cclkcfg=3
which gives me the output at 27MHz.
But the problem is that timer1 prescaler has to be set to 0,
T1PR=0;

For some reason I can't get the PLL to go any faster. So I can't do any operation to send data every 3 or 4 27MHz clock cycles.

I read the PLL problem in the errata for the LPC2387.
but my aim is Fcco)7MHz which doesnt exceeds the 300Mhz from the errata.

I can't use SPI/SSP since the clock has to be always active, and the data that is send doesnt match the exact clock, I have to send 360 bytes for 144 clock cycles.

Thanks.

--- In l..., Daniel Widyanto wrote:
>
> Hi,
>
> You could use one of MATx pins with Timerx peripheral (choice 1). It's better
> since you don't have to handle the interrupt. Hence, you got more MIPS to handle
> your firmware. But to get exact 27Mhz, you need to modify your running clock
> (PLL settings + dividers) (choice 2), so it'll run at integer multiple of 27Mhz.
>
> Here's some illustration of the LPCxxxx Timer peripheral (with matched registers
> name in orange):
>
> Hope that helps
>
> Regards,
> -daniel
>
> ----- Original Message ----
> From: franciscocantero1
> To: l...
> Sent: Sat, November 20, 2010 1:42:46 AM
> Subject: [lpc2000] clock on a GPIO, lpc2387
>
> Hello,
>
> I just join the group, how is everybody doing?
> over this week I try to get some code working with IAR, the project is nearly
> working, but I need to talk to a chip with an input of 27 MHz and send data at
> 6.9Mbps.
>
> I would like to know how to get a one of the GPIO pins to be a clock of 27MHz.
> My crystal is 12MHz. I thought of different ways of doing this:
>
> 1- do a PWM, but I dont know what kind of control I will have for being able to
> send some data in other line with 3 and 4 clock cycles of the 27MHz.
>
> 2- change the PLL setings to get a multiple of 27MHz, calculations where:
> M=9
> N=1
>
> 3- Do a counter and in the interrupt just toggle an output pin.
>
> This is the first time that I program an arm processor, I read the manual, but
> the section for timers doesnt specify if i can bring a clock out.
>
> Any help will be much apreciated.
>
> Thanks
>

Maybe, to send 0x55, send 0x0F0F0F0F instead to change data every 4th clock.
you shouldn't have trouble making the clock continuous (buffered SSP helps)
360 bytes in 144 clocks ... how many data lines?

--- In l..., "franciscocantero1" wrote:
>
> Hi,
>
> I had the wrong set up for the PLL, at the moment I can only get it to work with:
> M
> N=0
> clksrcsel=1
> cclkcfg=3
> which gives me the output at 27MHz.
> But the problem is that timer1 prescaler has to be set to 0,
> T1PR=0;
>
> For some reason I can't get the PLL to go any faster. So I can't do any operation to send data every 3 or 4 27MHz clock cycles.
>
> I read the PLL problem in the errata for the LPC2387.
> but my aim is Fcco)7MHz which doesnt exceeds the 300Mhz from the errata.
>
> I can't use SPI/SSP since the clock has to be always active, and the data that is send doesnt match the exact clock, I have to send 360 bytes for 144 clock cycles.
>

Sorry it isn't 360 bytes, it is 45 bytes that make the 360 but bits.
And it is in one data line.

--- In l..., "John S" wrote:
> Maybe, to send 0x55, send 0x0F0F0F0F instead to change data every 4th clock.
> you shouldn't have trouble making the clock continuous (buffered SSP helps)
> 360 bytes in 144 clocks ... how many data lines?
>
> --- In l..., "franciscocantero1" wrote:
> >
> > Hi,
> >
> > I had the wrong set up for the PLL, at the moment I can only get it to work with:
> > M
> > N=0
> > clksrcsel=1
> > cclkcfg=3
> >
> >
> > which gives me the output at 27MHz.
> > But the problem is that timer1 prescaler has to be set to 0,
> > T1PR=0;
> >
> > For some reason I can't get the PLL to go any faster. So I can't do any operation to send data every 3 or 4 27MHz clock cycles.
> >
> > I read the PLL problem in the errata for the LPC2387.
> > but my aim is Fcco)7MHz which doesnt exceeds the 300Mhz from the errata.
> >
> > I can't use SPI/SSP since the clock has to be always active, and the data that is send doesnt match the exact clock, I have to send 360 bytes for 144 clock cycles.
>

So in 5 1/3 uS, you want 144 clock cycles, and 360 data bits?
that puts the data rate up at 67.5 Mhz which isn't possible with this processor.
The best I think you can do for data out is going to be with the SSP at 1/2 of PCLK. (bit banging will be much slower)
To produce a fast clock that isn't the data clock, you'd have to use the timer or PWM and use automatic counter resetting. With external Xor gates you might be able to get the PWM to produce a funky clock that has 6 edges over some (not multiple of 6) number of PCLK cycles.
--- In l..., "franciscocantero1" wrote:
> Sorry it isn't 360 bytes, it is 45 bytes that make the 360 but bits.
> And it is in one data line.
>
> --- In l..., "John S" wrote:
> >
> >
> > Maybe, to send 0x55, send 0x0F0F0F0F instead to change data every 4th clock.
> > you shouldn't have trouble making the clock continuous (buffered SSP helps)
> > 360 bytes in 144 clocks ... how many data lines?
> >
> > --- In l..., "franciscocantero1" wrote:
> > >
> > > Hi,
> > >
> > > I had the wrong set up for the PLL, at the moment I can only get it to work with:
> > > M
> > > N=0
> > > clksrcsel=1
> > > cclkcfg=3
> > >
> > >
> > > which gives me the output at 27MHz.
> > > But the problem is that timer1 prescaler has to be set to 0,
> > > T1PR=0;
> > >
> > > For some reason I can't get the PLL to go any faster. So I can't do any operation to send data every 3 or 4 27MHz clock cycles.
> > >
> > > I read the PLL problem in the errata for the LPC2387.
> > > but my aim is Fcco)7MHz which doesnt exceeds the 300Mhz from the errata.
> > >
> > > I can't use SPI/SSP since the clock has to be always active, and the data that is send doesnt match the exact clock, I have to send 360 bytes for 144 clock cycles.
> > >
>

Hello,

Sorry for the confusion,
the requirement is to send:

37 bits in 144 clock cycles.

--- In l..., "John S" wrote:
>
> So in 5 1/3 uS, you want 144 clock cycles, and 360 data bits?
> that puts the data rate up at 67.5 Mhz which isn't possible with this processor.
> The best I think you can do for data out is going to be with the SSP at 1/2 of PCLK. (bit banging will be much slower)
> To produce a fast clock that isn't the data clock, you'd have to use the timer or PWM and use automatic counter resetting. With external Xor gates you might be able to get the PWM to produce a funky clock that has 6 edges over some (not multiple of 6) number of PCLK cycles.
> --- In l..., "franciscocantero1" wrote:
> >
> >
> > Sorry it isn't 360 bytes, it is 45 bytes that make the 360 but bits.
> > And it is in one data line.
> >
> > --- In l..., "John S" wrote:
> > >
> > >
> > > Maybe, to send 0x55, send 0x0F0F0F0F instead to change data every 4th clock.
> > > you shouldn't have trouble making the clock continuous (buffered SSP helps)
> > > 360 bytes in 144 clocks ... how many data lines?
> > >
> > > --- In l..., "franciscocantero1" wrote:
> > > >
> > > > Hi,
> > > >
> > > > I had the wrong set up for the PLL, at the moment I can only get it to work with:
> > > > M
> > > > N=0
> > > > clksrcsel=1
> > > > cclkcfg=3
> > > >
> > > >
> > > > which gives me the output at 27MHz.
> > > > But the problem is that timer1 prescaler has to be set to 0,
> > > > T1PR=0;
> > > >
> > > > For some reason I can't get the PLL to go any faster. So I can't do any operation to send data every 3 or 4 27MHz clock cycles.
> > > >
> > > > I read the PLL problem in the errata for the LPC2387.
> > > > but my aim is Fcco)7MHz which doesnt exceeds the 300Mhz from the errata.
> > > >
> > > > I can't use SPI/SSP since the clock has to be always active, and the data that is send doesnt match the exact clock, I have to send 360 bytes for 144 clock cycles.
> > > >
> > >
>

--- In l..., "franciscocantero1" wrote:
>
> Hello,
>
> Sorry for the confusion,
> the requirement is to send:
>
> 37 bits in 144 clock cycles.

You still don't have it right !!

144 / 37 = 3.8918918918918918918918918918919

It would be easier if you just say what your trying to do and be done with it.

Being cryptic only drags this discussion out with no useful results.

don
>
> --- In l..., "John S" wrote:
> >
> > So in 5 1/3 uS, you want 144 clock cycles, and 360 data bits?
> > that puts the data rate up at 67.5 Mhz which isn't possible with this processor.
> > The best I think you can do for data out is going to be with the SSP at 1/2 of PCLK. (bit banging will be much slower)
> > To produce a fast clock that isn't the data clock, you'd have to use the timer or PWM and use automatic counter resetting. With external Xor gates you might be able to get the PWM to produce a funky clock that has 6 edges over some (not multiple of 6) number of PCLK cycles.
> >
> >
> > --- In l..., "franciscocantero1" wrote:
> > >
> > >
> > > Sorry it isn't 360 bytes, it is 45 bytes that make the 360 but bits.
> > > And it is in one data line.
> > >
> > > --- In l..., "John S" wrote:
> > > >
> > > >
> > > > Maybe, to send 0x55, send 0x0F0F0F0F instead to change data every 4th clock.
> > > > you shouldn't have trouble making the clock continuous (buffered SSP helps)
> > > > 360 bytes in 144 clocks ... how many data lines?
> > > >
> > > > --- In l..., "franciscocantero1" wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I had the wrong set up for the PLL, at the moment I can only get it to work with:
> > > > > M
> > > > > N=0
> > > > > clksrcsel=1
> > > > > cclkcfg=3
> > > > >
> > > > >
> > > > > which gives me the output at 27MHz.
> > > > > But the problem is that timer1 prescaler has to be set to 0,
> > > > > T1PR=0;
> > > > >
> > > > > For some reason I can't get the PLL to go any faster. So I can't do any operation to send data every 3 or 4 27MHz clock cycles.
> > > > >
> > > > > I read the PLL problem in the errata for the LPC2387.
> > > > > but my aim is Fcco)7MHz which doesnt exceeds the 300Mhz from the errata.
> > > > >
> > > > > I can't use SPI/SSP since the clock has to be always active, and the data that is send doesnt match the exact clock, I have to send 360 bytes for 144 clock cycles.
> > > > >
> > > >
> > >
>

Hi,

As a rough guess I'd suggest you're trying to talk to an Analog
Devices video chip. 27MHz is a standard video data rate, and I know
Analog Devices does these kind of video chips.

Neil
--
http://www.njohnson.co.uk

Memfault Beyond the Launch