Discussion in "ARM Development" started by    shyam    Dec 22, 2007.
Sun Dec 23 2007, 05:15 pm
#21
IO1PIN=0xFFFFFFFF;
IO1PIN=0xFFFFFFFF;
IO0PIN=~pin;
Well as per manual definition above statements should not have any effect on working of program .
So if i remove these from program board functioning should remain same .
Am i right Shyam?
Sun Dec 23 2007, 05:32 pm
#22
vinay...
IO1PIN=0xFFFFFFFF;

=> IOSET1 = 0xFFFFFFFF;

if IODIR1 = 0xFFFFFFFF;

similarly....

IO0PIN = ~ pin .. wil call both IOSET and IOCLR...

i didnt want to confuse u so i said u have got it wrong.....

ur programme wud work...

but as beginner u shud avoid using IOPIN = statements directly.....

better use IOSET and IOCLR...
when writing large programmes u will get my point...
for the time being ... nd for ur question...
yes u can write to IOPIN and t will internally generate the two sets of instructions IOSET n IOCLR... but not recommended..!!


thus finally ur programe will run..

but i recommend modifications...

 vinay1277 like this.
Sun Dec 23 2007, 05:52 pm
#23
#define T0PR (*((volatile WORD32 *) 0xE000400C))
#define VPBDIV (*((volatile WORD32 *) 0xE01FC100))
#define IO1PIN (*((volatile WORD32 *) 0xE0028010))
#define IO1SET (*((volatile WORD32 *) 0xE0028014))
#define IO1DIR (*((volatile WORD32 *) 0xE0028018))
#define IO1CLR (*((volatile WORD32 *) 0xE002801C))

well since u r using SCARM... u have to define the names of register else...

u will find them in LPC2138.h
volatile (WORD32 * address) refers to a 32 bit address ie. address

u neednt bother abt it....

they always remain the same..

 mheldiana1234 like this.
Mon Dec 24 2007, 07:24 pm
#24
well

hope now
IODIR
IOSET
IOCLR
IOPIN
are all clear now.....

now we can start by interfacing a 16 x2 lcd on ARM???
this is a very simple programme.. no timers no interrupts nothing... just GPIOS
it is not an optimised code... just will give u idea of what can u do with GPIOs

here it goes...


#include <LPC213X.H>

#include "string.h"
#include <stdio.h>

/*
    LCD connections:
    P0.20   P0.23   P0.19   P0.18   P0.17   P0.16
    RS  EN  D7  D6  D5  D4
    4 bit interface is used.
*/

void SmallDelay ()
{
/*
    does nothing, but produces small delay due to call and return instructions
*/
}
void LcdCmd1 (unsigned char cmd)
{
    unsigned int temp ;

    IOSET0 = temp = 0x0F0000 & (cmd << 16) ;
    IOCLR0 = (temp ^ 0x0F0000) | 0x900000 ;

    SmallDelay() ;
    IOSET0 = 0x800000 ;
    SmallDelay() ;
    IOCLR0 = 0x800000 ;
    SmallDelay() ;
}
void LcdDat1 (unsigned char dat)
{
    unsigned int temp ;

    IOSET0 = temp = (0x0F0000 & (dat << 16)) | 0x100000 ;
    IOCLR0 = (temp ^ 0x1F0000) | 0x800000 ;

    SmallDelay() ;
    IOSET0 = 0x800000 ;
    SmallDelay() ;
    IOCLR0 = 0x800000 ;
    SmallDelay() ;
}
void Delay250 ()
{
    int k ;
    for(k = 0 ; k < 100 ; k ++)
    {
    }
}
void DelayMs (int n)
{
    int k ;
    for(k = 0 ; k < n ; k ++)
    {
        Delay250() ;
        Delay250() ;
        Delay250() ;
        Delay250() ;
    }
}
void LcdCmd (unsigned char cmd)
{
    LcdCmd1(cmd >
>
 4) ;
    LcdCmd1(cmd) ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
}
void LcdDat (unsigned char dat)
{
    LcdDat1(dat >
>
 4) ;
    LcdDat1(dat) ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;

}
void LcdInit ()
{
    IODIR0 = 0x9F0000 ;
    IOCLR0 = 0x9F0000 ;
    DelayMs(15) ;
    DelayMs(15) ;
    DelayMs(15) ;
    DelayMs(15) ;
    LcdCmd1(0x03) ;
    DelayMs(6) ;
    DelayMs(6) ;
    DelayMs(6) ;
    DelayMs(6) ;
    LcdCmd1(0x03) ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    LcdCmd1(0x03) ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    LcdCmd1(0x02) ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;
    Delay250() ;

    LcdCmd(0x28) ;
    LcdCmd(0x08) ;
    LcdCmd(0x0c) ;
    LcdCmd(0x06) ;
}
void DisplayRow(int row, char *str)
{
/*
    pass pointer to 16 character string
    displayes the message on line1 or line2 of LCD, depending on whether row is 1 or 2.
*/
    int k ;

    if (row == 1)
        LcdCmd(0x80) ;
    else
        LcdCmd(0xc0) ;
    for(k = 0 ; k < 16 ; k ++)
    {
        if (str[k])
            LcdDat(str[k]) ;
        else
            break ;
    }
    while(k < 16)
    {
        LcdDat(' ') ;
        k ++ ;
    }
}

void ClearLine(int row)
{
    char szTemp[17] ;
    sprintf(szTemp,"                ") ;
	DisplayRow(row,szTemp) ;

}

int main()
{
 LcdInit();

  DisplayRow(1,"hello shyam");
return 0;
}


try it out on a simulators or hardware if u can...
before that try and understand the bitwise operations....
i 've removed most of the comments... so u do hve some doubts...
that will make ur understanding clearer
Fri Dec 28 2007, 06:54 pm
#25
From little knowledge i have gained recently i wish to convey following
1. Since in ARM port pins are not bit addressable we can use IO0SET and IO0CLR as tool to set/reset specific bit in a specific port without bothering about and changing status of other pins in the port .
2. Actual time of operation or execution of IO0SET and IO0CLR are different . So if your application desires simultaneous status change of status from set to reset and vice versa then use of IO0SET and IO0CLR may cause error in high resolution time dependent applications .
3. Above problem is overcome by using IO0PIN . Unlike IO0SET and IO0CLR where O does not have any effect , 0 does and 1 both update pin status accordingly and time difference is not there as mentioned in point 2
4. Since in IO0PIN 0 matters it is very important for programmer to see if there is any possible undesired change in PIN status by using IO0PIN . If yes then necessary corrective/ preventive steps in terms of appropriate BOOLEAN operation is required otherwise it may result in undesired/ unpredictable results.
Hence use IO0PIN demands caution and use of IO0SET and IO0CLR is suggested .
Shyam please correct if i am wrong and may i request you to start RTC and UART if possible togather or UART first.
Shyam start discussion/tutorial on UART
Fri Dec 28 2007, 07:19 pm
#26
all right now...

thanks vinay1277 for giving exact summarry of this tutorial..
we shall move on to UAR then....

Ajay we shud now close this discussion here ....
Fri Dec 28 2007, 07:40 pm
#27
discussion should not be closed..
actually u posted in the wrong area.. :-s
Wed Jan 27 2010, 08:45 pm
#28
guys,
i know its a very old post, but i need some help.

i am trying to glow an led connected on p0.22 when ever a button connected on p1.16 is pressed. i have tried all possible combination's and still am hopelessly lost!

can some one please help me with this:

#include <LPC214x.H> /* LPC21xx definitions */
#define SW 16

int main (void)
{

IO0DIR = 0X00400000; //P0.22 AS OUTPUT
IO1DIR = 0X00000000; // P1.16 AS INPUT

while (1)
{
if((IO1PIN &(1<< SW)))

IO0SET = 0X00400000;
else
IO0CLR = 0x00400000;

}
}

thanks in advance for any help that is going to come my way!

Fri Jan 29 2010, 01:01 am
#29


guys,
i know its a very old post, but i need some help.

i am trying to glow an led connected on p0.22 when ever a button connected on p1.16 is pressed. i have tried all possible combination's and still am hopelessly lost!

can some one please help me with this:

#include /* LPC21xx definitions */
#define SW 16

int main (void)
{

IO0DIR = 0X00400000; //P0.22 AS OUTPUT
IO1DIR = 0X00000000; // P1.16 AS INPUT

while (1)
{
if((IO1PIN &(1<< SW)))

IO0SET = 0X00400000;
else
IO0CLR = 0x00400000;

}
}

thanks in advance for any help that is going to come my way!


v_ants



i dont find any problem with code, just make sure your hardware is fine. tell me how exactly your hardware is behaving?
Sun Jan 31 2010, 11:00 am
#30


guys,
i know its a very old post, but i need some help.

i am trying to glow an led connected on p0.22 when ever a button connected on p1.16 is pressed. i have tried all possible combination's and still am hopelessly lost!

can some one please help me with this:

#include /* LPC21xx definitions */
#define SW 16

int main (void)
{

IO0DIR = 0X00400000; //P0.22 AS OUTPUT
IO1DIR = 0X00000000; // P1.16 AS INPUT

while (1)
{
if((IO1PIN &(1<< SW)))

IO0SET = 0X00400000;
else
IO0CLR = 0x00400000;

}
}

thanks in advance for any help that is going to come my way!


v_ants


assuming u are working at 60Mhz.. just imagine how much less time u give for the led to glow!
to test remove the else statement and see if the led glows continuously after the key has been pressed for the first time. then experiment by adding dedlay routines.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

ArktiTic
Sun May 05 2024, 07:06 pm
CesslasyNear
Sun May 05 2024, 02:58 pm
chimichmedic1204
Sun May 05 2024, 11:06 am
Jamiegob
Sun May 05 2024, 10:11 am
Gregoryjed
Sun May 05 2024, 10:02 am
Mariocax
Sun May 05 2024, 08:51 am
WilliamErync
Sun May 05 2024, 02:35 am
Danielnof
Sat May 04 2024, 11:12 pm