Reply by Michael Anton●December 23, 20102010-12-23
> -----Original Message-----
> From: l...
> [mailto:l...]On Behalf
> Of roelof 't Hooft
> Sent: Thursday, December 23, 2010 3:54 AM
> To: l...
> Subject: Re: [lpc2000] Loading data serially on a GPIO pin.
> On Thu, 2010-12-23 at 15:38 +0530, Dhinesh Kumar wrote:
> > unsigned char data_to_send[] = {0x01,0x00};
>
> Better yet :
>
> #define dts_length 2
> unsigned char data_to_send[dts_length] = {0x01,0x00};
>
> .....
> for(byte_idx = 0; byte_idx < dts_length; byte_idx++)
> roelof
>
This is not an improvement. What the OP had originally is better
because it scales with the size of the array. Your method gives
the same result, but requires the programmer to do more work
rather than letting the compiler do it for him. Now you have to
change dts_length everytime data_to_send is changed in length.
Mike
Reply by roelof 't Hooft●December 23, 20102010-12-23
On Thu, 2010-12-23 at 15:38 +0530, Dhinesh Kumar wrote: > unsigned char data_to_send[] = {0x01,0x00};
I find it more clearly to use hex numbers for a statement
in the line above, like :
if(to_send & 0x01)
roelof
Reply by Timo●December 23, 20102010-12-23
On 12/23/2010 12:08 PM, Dhinesh Kumar wrote: > I already tried that method of spiting bytes to bits
and feeding them to
> GPIO that too dosent works. This is the program of it.
*How* it doesn't work. For example, do you see *any* of the signals
toggling (if not, hint: are you sure you have set them output).
--
Timo
Reply by Dhinesh Kumar●December 23, 20102010-12-23
I had done that to my friend but it doesn't works. Program compiles it but
on hardware implementation its not working.
Regards
Dhinesh Kumar .R
Embedded Developer (R&D)
Hawk Technologies Pvt Ltd
--- On Thu, 23/12/10, roelof 't Hooft wrote:
From: roelof 't Hooft
Subject: Re: [lpc2000] Loading data serially on a GPIO pin.
To: l...
Date: Thursday, 23 December, 2010, 9:13 AM
On Thu, 2010-12-23 at 11:06 +0200, Timo wrote:
> You already know how to raise or lower the Latch and
Clock pins. How
> come that you can't solve the same problem with
the Data pin?
I think he does not know how to convert the bytes
to a bit pattern on the IO pin.
For example : in bu[] he has 4 bytes and in the
for() loop he indexes it as being 8 bytes.
roelof
Reply by simonb65●December 23, 20102010-12-23
Why are you rotating your bytes, passed in to your serialize function, by 16 ? A
byte only has 8 bits!!!!!!!
--- In l..., Dhinesh Kumar wrote: >
> I already tried that method of spiting bytes to bits and feeding them to GPIO
that too dosent works. This is the program of it.
>
> #include
>
> #define Data_Pin (1 << 21)
> #define Data_DIR_SET (IO0DIR |= Data_Pin)
> #define Data_SET (IO0SET = Data_Pin)
> #define Data_CLR (IO0CLR = Data_Pin)
>
> #define Clock (1 << 22)
> #define Clock_DIR_SET (IO0DIR |= Clock)
> #define Clock_SET (IO0SET = Clock)
> #define Clock_CLR (IO0CLR = Clock)
>
> #define Latch (1 << 23)
> #define Latch_DIR_SET (IO0DIR |= Latch)
> #define Latch_SET (IO0SET = Latch)
> #define Latch_CLR (IO0CLR = Latch)
>
> #define S_Length(a) (sizeof(a) / sizeof(*(a)))
>
> unsigned byte_idx;
> unsigned char data_to_send[] = {0x01,0x00};
> unsigned int i;
>
>
> void delay(int count)
> {
> int j=0,i=0;
>
> for(j=0;j
> {
> /* At 60Mhz, the below loop introduces
> delay of 10 us */
> for(i=0;i<35;i++);
> }
> }
>
> void Data_load(unsigned char to_send)
> {
> Clock_CLR;
> Latch_CLR;
> for (i = 0; i < 16; i++){
>
> if (to_send & 1) {
>
> Data_SET;
>
}
> else {
>
>
Data_CLR;
>
}
>
> to_send >>= 1;
> //delay(1);
> Clock_SET ;
> delay(1);
> Clock_CLR;
> delay(1);
> }
> Latch_SET;
> delay(10);
> Latch_CLR;
> }
>
> int main(void)
> {
>
> while(1)
> {
>
> for (byte_idx = 0; byte_idx <
S_Length(data_to_send); byte_idx++)
> {
>
>
Data_load(data_to_send[byte_idx]);
>
> }
>
> }
>
> }
>
>
> Regards
>
> Dhinesh Kumar .R
>
> Embedded Developer (R&D)
>
> Hawk Technologies Pvt Ltd
>
> --- On Thu, 23/12/10, Timo wrote:
>
> From: Timo
> Subject: Re: [lpc2000] Loading data serially on a GPIO pin.
> To: l...
> Date: Thursday, 23 December, 2010, 9:06 AM
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On 12/23/2010 10:50 AM, Dhinesh wrote:
>
> > That's wrong, but i need to load data to particular pin so that i
>
> > reffered to (1<<21), thats wrong i too know. please provide the
>
> > solution. I could have used IOPIN0 register, but that wont work.
>
>
>
> You already know how to raise or lower the Latch and Clock pins. How
>
> come that you can't solve the same problem with the Data pin?
>
>
>
> --
>
>
>
> Timo
>
Reply by Dhinesh Kumar●December 23, 20102010-12-23
I already tried that method of spiting bytes to bits and feeding them to GPIO
that too dosent works. This is the program of it.
for (byte_idx = 0; byte_idx <
S_Length(data_to_send); byte_idx++)
{
Data_load(data_to_send[byte_idx]);
}
}
}
Regards
Dhinesh Kumar .R
Embedded Developer (R&D)
Hawk Technologies Pvt Ltd
--- On Thu, 23/12/10, Timo wrote:
From: Timo
Subject: Re: [lpc2000] Loading data serially on a GPIO pin.
To: l...
Date: Thursday, 23 December, 2010, 9:06 AM
On 12/23/2010 10:50 AM, Dhinesh wrote:
> That's wrong, but i need to load data to
particular pin so that i
> reffered to (1<<21), thats wrong i too know. please
provide the
> solution. I could have used IOPIN0 register, but that
wont work.
You already know how to raise or lower the Latch and Clock pins. How
come that you can't solve the same problem with the Data pin?
--
Timo
Reply by roelof 't Hooft●December 23, 20102010-12-23
On Thu, 2010-12-23 at 11:06 +0200, Timo wrote: > You already know how to raise or lower the Latch and
Clock pins. How
> come that you can't solve the same problem with the Data pin?
I think he does not know how to convert the bytes
to a bit pattern on the IO pin.
For example : in bu[] he has 4 bytes and in the
for() loop he indexes it as being 8 bytes.
roelof
Reply by Timo●December 23, 20102010-12-23
On 12/23/2010 10:50 AM, Dhinesh wrote: > That's wrong, but i need to load data to
particular pin so that i
> reffered to (1<<21), thats wrong i too know. please provide the
> solution. I could have used IOPIN0 register, but that wont work.
You already know how to raise or lower the Latch and Clock pins. How
come that you can't solve the same problem with the Data pin?