From: selmaguzel on
Hi,
But I haven't been able to understand the exact logic of the example below:

int gpio3 = (1 << 3);

// map all of GPIO space
PhysicalAddressPointer pap;
pap = new PhysicalAddressPointer(0x40E00000, 0x6B);

// make an GPIO output
int gpdr = pap.ReadInt32(0x10);
pap.WriteInt32(gpdr | gpio3);

while(true)
{
// turn it off
pap.WriteInt32(gpio3, 0x24);

// turn it on
pap.WriteInt32(gpio3, 0x18);
}




For example what does "int gpio3 = (1 << 3)" phrase mean?

Can you explain?

According to my understanding, I wrote an example as below:

gpbcon = new PhysicalAddressPointer(0x56000010, 0x04); //0x56000010 > GPCONB
register's address

gpbdata = new PhysicalAddressPointer(0x56000014, 0x04); // 0x56000014 >
GPPORTB register's address

gpbcon.WriteInt32(0X00); // Set the GPPORTB as output register

gpbdata.WriteInt16(0x00); // Clear GPPORTB



And PORTB is connected to the leds.

But after running this code, the leds didn't turn off.



Why?

Thanks.






"selmaguzel" wrote:

> Hi,
> Thanks for your reply.
> After changing the address for my sbc i have gotten result:
> PhysicalAddressPointer gpacon, gpadata;
>
> gpacon = new PhysicalAddressPointer(0x56000010, 0x04);
> gpadata = new PhysicalAddressPointer(0x56000014, 0x04);
>
> gpacon.WriteInt32(0X00); // GPBCON set GPBDAT as output port.
>
> gpadata.WriteInt32(0x01); // Write to gpadata
> textBox1.Text=gpadata.ReadByte().ToString();
>
> That's all:) Of course according to your suggestions;)
> Thanks.
>
>
>
>
>
> "Chris Tacke, MVP" wrote:
>
> > Registers and mapped IO are very, very hardware dependent so I can't really
> > provide an example that's going to be a whole lot of use (unless we just
> > amazingly have the same hardware). The PhysicalAddressPointer class is
> > really straightforward - you give it an address to map and then you read or
> > write to it just like you would in C.
> >
> > Something like this
> >
> > PhysicalAddressPointer pap = new PhysicalAddressPointer(myAddress, size);
> > pap.WriteInt32(myIntvalue);
> > myIntvalue = pap.ReadInt32();
> >
> > -Chris
> >
> >
> >
> > "Selma G?zel" wrote in message news:20086248537slm_guzel(a)hotmail.com...
> > > Hi,
> > > Can you give a link for an exact sample or send a simple code to this
> > > address:slm_guzel(a)hotmail.com
> > > ?
> > > Thanks in advance.
> >
From: selmaguzel on
I haven't been able to solved my problem yet.

And i hope if you check some informations about gpio register,you will be
able to help me.

These are some informations for gpio portb for my board:

led1:b5
led2:b6
led3:b7
led4:b8

S3C2440A RISC MICROPROCESSOR

PORT B CONTROL REGISTERS (GPBCON, GPBDAT, GPBUP)
Register Address R/W Description Reset Value
GPBCON 0x56000010 R/W Configures the pins of port B 0x0
GPBDAT 0x56000014 R/W The data register for port B Undef.
GPBUP 0x56000018 R/W Pull-up disable register for port B 0x0
Reserved 0x5600001c

PBCON Bit Description
GPB10 [21:20] 00 = Input 01 = Output
10 = nXDREQ0 11 = reserved
GPB9 [19:18] 00 = Input 01 = Output
10 = nXDACK0 11 = reserved
GPB8 [17:16] 00 = Input 01 = Output
10 = nXDREQ1 11 = Reserved
GPB7 [15:14] 00 = Input 01 = Output
10 = nXDACK1 11 = Reserved
GPB6 [13:12] 00 = Input 01 = Output
10 = nXBREQ 11 = reserved
GPB5 [11:10] 00 = Input 01 = Output
10 = nXBACK 11 = reserved
GPB4 [9:8] 00 = Input 01 = Output
10 = TCLK [0] 11 = reserved
GPB3 [7:6] 00 = Input 01 = Output
10 = TOUT3 11 = reserved
GPB2 [5:4] 00 = Input 01 = Output
10 = TOUT2 11 = reserved]
GPB1 [3:2] 00 = Input 01 = Output
10 = TOUT1 11 = reserved
GPB0 [1:0] 00 = Input 01 = Output
10 = TOUT0 11 = reserved

GPBDAT Bit Description
GPB[10:0] [10:0] When the port is configured as input port, the
corresponding bit is the pin
state. When the port is configured as output port, the pin state is the same
as the corresponding bit. When the port is configured as functional pin, the
undefined value will be read.

GPBUP Bit Description
GPB[10:0] [10:0] 0: The pull up function attached to the corresponding port
pin is enabled.
1: The pull up function is disabled.



The informations below are from a file in the bsp.

void ConfigStopGPIO(void)
{
volatile IOPreg *s2440IOP = (IOPreg *)IOP_BASE;

// Check point
// 1) NC pin: input pull-up on
// 2) If input is driver externally: input pull-up off
// 3) If a connected component draws some current: output low.
// 4) If a connected component draws no current: output high.

//chip # = 5

//CAUTION:Follow the configuration order for setting the ports.
// 1) setting value(GPnDAT)
// 2) setting control register (GPnCON)
// 3) configure pull-up resistor(GPnUP)

//32bit data bus configuration
//*** PORT A GROUP
//Ports : GPA22 GPA21 GPA20 GPA19 GPA18 GPA17 GPA16 GPA15 GPA14 GPA13
GPA12
//Signal : nFCE nRSTOUT nFRE nFWE ALE CLE nGCS5 nGCS4 nGCS3 nGCS2
nGCS1
//Binary : 1 1 1, 1 1 1 1, 1 1 1 1,
//POFF : 1 0 1, 1 0 0 1, 1 1 1 1,

//-------------------------------------------------------------------------------------------
//Ports : GPA11 GPA10 GPA9 GPA8 GPA7 GPA6 GPA5 GPA4 GPA3
GPA2 GPA1 GPA0
//Signal : ADDR26 ADDR25 ADDR24 ADDR23 ADDR22 ADDR21 ADDR20 ADDR19
ADDR18 ADDR17 ADDR16 ADDR0
//Binary : 1 1 1 1, 1 1 1 1, 1
1 1 1
//POFF : 0 0 0 0, 0 0 0 0, 0
0 0 0
s2440IOP->rGPACON = 0x7fffff;

//**** PORT B GROUP
//Ports : GPB10 GPB9 GPB8 GPB7 GPB6 GPB5 GPB4 GPB3
GPB2 GPB1 GPB0
//Signal : nXDREQ0 nXDACK0 nXDREQ1 nXDACK1 nSS_KBD nDIS_OFF L3CLOCK
L3DATA L3MODE nIrDATXDEN Keyboard
//Setting: INPUT OUTPUT INPUT OUTPUT INPUT OUT OUT OUT
OUT INPUT INPUT
//Binary : 00, 01 00, 01 00, 01 01, 01
01, 00 00 (org)
//Binary : 00, 01 01, 01 01, 01 01, 01
01, 00 00
//PU_OFF : 0 1 0, 1 1(ext) 1(*) 1, 1
1 1(ext) 1(ext) (org)
//PU_OFF : 0 1 1, 1 1(ext) 1(*) 1, 1
1 1(ext) 1(ext)
//*:nDIS_OFF:4.7K external pull-down resistor

// s2440IOP->rGPBDAT= 0x0|(1<<9)|(1<<7)|(0<<5)|(1<<4)|(1<<3)|(1<<2);
s2440IOP->rGPBDAT=
0x0|(0<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2); // SHLIM 040116
s2440IOP->rGPBCON = 0x055550;
s2440IOP->rGPBUP = 0x3ff; //0x2fd->2ff, 3uA is reduced. Why?

//*** PORT C GROUP
//Ports : GPC15 GPC14 GPC13 GPC12 GPC11 GPC10 GPC9 GPC8 GPC7 GPC6
GPC5 GPC4 GPC3 GPC2 GPC1 GPC0
//Signal : VD7 VD6 VD5 VD4 VD3 VD2 VD1 VD0 LCDVF2 LCDVF1
LCDVF0 VM VFRAME VLINE VCLK LEND
//Setting: IN IN IN IN IN IN IN IN OUT OUT
OUT IN IN IN IN IN
//Binary : 00 00, 00 00, 00 00, 00 00, 01 01, 01
00, 00 00, 00 00
//PU_OFF : 0 0 0 0, 0 0 0 0, 1 1 1
0, 0 0 0 0
s2440IOP->rGPCDAT = 0x0;
s2440IOP->rGPCCON = 0x00005400; //0x00000000;
s2440IOP->rGPCUP = 0x00e0; //0x0000;
//LCDVFn is connected the analog circuit in LCD. So, this signal should
be output L.

//*** PORT D GROUP
//Ports : GPD15 GPD14 GPD13 GPD12 GPD11 GPD10 GPD9 GPD8 GPD7 GPD6 GPD5
GPD4 GPD3 GPD2 GPD1 GPD0
//Signal : VD23 VD22 VD21 VD20 VD19 VD18 VD17 VD16 VD15 VD14 VD13
VD12 VD11 VD10 VD9 VD8
//Setting: IN IN IN IN IN IN IN IN IN IN IN
IN IN IN IN IN
//Binary : 00 00, 00 00, 00 00, 00 00, 00 00, 00
00, 00 00, 00 00
//PU_OFF : 0 0 0 0, 0 0 0 0, 0 0 0
0, 0 0 0 0
s2440IOP->rGPDDAT= 0x0;
s2440IOP->rGPDCON = 0x0;
s2440IOP->rGPDUP = 0x0;

//*** PORT E GROUP
//Ports : GPE15 GPE14 GPE13 GPE12 GPE11 GPE10 GPE9 GPE8
GPE7 GPE6 GPE5 GPE4
//Signal : IICSDA IICSCL SPICLK0 SPIMOSI0 SPIMISO0 SDDATA3 SDDATA2
SDDATA1 SDDATA0 SDCMD SDCLK I2SSDO
//Setting: IN IN IN IN IN IN IN IN
IN IN IN OUT
//Binary : 00 00, 00 00, 00 00, 00 00,
00 00, 00 01,
//PU_OFF : 1-ext 1-ext 0 0, 0 0 0 0,
0 0 0 1,

//------------------------------------------------------------------------------------------------
//Ports : GPE3 GPE2 GPE1 GPE0
//Signal : I2SSDI CDCLK I2SSCLK I2SLRCK
//Setting: IN OUT OUT OUT
//Binary : 00 01, 01 01
//PU_OFF : 1-ext 1 1 1
s2440IOP->rGPEDAT = 0x0|(1<<4)|(1<<2)|(1<<1)|(1<<0);
s2440IOP->rGPECON = 0x00000115;
s2440IOP->rGPEUP = 0xc01f;

//*** PORT F GROUP
//Ports : GPF7 GPF6 GPF5 GPF4 GPF3 GPF2 GPF1 GPF0
//Signal : nLED_8 nLED_4 nLED_2 nLED_1 nIRQ_PCMCIA EINT2 KBDINT EINT0
//Setting: Output Output Output Output IN IN IN EINT0
//Binary : 01 01, 01 01, 00 00, 00 10
//PU_OFF : 1 1 1 1, 0-ext 1-ext 1-ext 1-ext
s2440IOP->rGPFDAT = 0x0 |(0xf<<4);
s2440IOP->rGPFCON = 0x5502;
s2440IOP->rGPFUP = 0xf7;

//*** PORT G GROUP
//Ports : GPG15 GPG14 GPG13 GPG12 GPG11 GPG10 GPG9 GPG8
GPG7 GPG6
//Signal : nYPON YMON nXPON XMON EINT19 DMAMODE1 DMAMODE0 DMASTART
KBDSPICLK KBDSPIMOSI
//Setting: OUT OUT OUT OUT OUT OUT OUT OUT OUT
OUT
//Binary : 01 01, 01 01, 01-dbg 01, 01 01, 01
01
//PU_OFF : 1 1 1 1, 1-ext 1 1 1, 1
1

//---------------------------------------------------------------------------------------
//Ports : GPG5 GPG4 GPG3 GPG2 GPG1 GPG0
//Signal : KBDSPIMISO LCD_PWREN EINT11 nSS_SPI IRQ_LAN IRQ_PCMCIA
//Setting: IN IN EINT11 IN IN IN
//Binary : 00 00, 10 00, 00 00
//PU_OFF : 0-ext 0, 1-ext 0 0 0
#if 0
s2440IOP->rGPGDAT = 0x0
|(1<<11)|(1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<9)|(1<<8)|(1<<7)|(1<<6) ;
s2440IOP->rGPGCON = 0x55455080; //GPG11=OUT //for debug
s2440IOP->rGPGUP = 0xfbc8;
#else // Modified for 2440
s2440IOP->rGPGDAT = 0;
s2440IOP->rGPGCON = 0x00000000;
s2440IOP->rGPGUP = 0x0;
#endif

//*** PORT H GROUP
//Ports : GPH10 GPH9 GPH8 GPH7 GPH6 GPH5 GPH4 GPH3 GPH2 GPH1
GPH0
//Signal : CLKOUT1 CLKOUT0 UCLK nCTS1 nRTS1 RXD1 TXD1 RXD0 TXD0 nRTS0
nCTS0
//Setting: IN IN IN IN IN IN OUT RXD0 TXD0 OUT IN
//Binary : 00, 00 00, 00 00, 00 01, 10 10, 01 00
//PU_OFF : 0 0 0, 1-ext 1-ext 1-ext 1, 1-ext 1 1
1-ext

#if 1
s2440IOP->rGPHDAT = 0x0|(1<<6)|(1<<1)|(1<<4);
s2440IOP->rGPHCON = 0x0001a4; //0x0011a4->0x0001a4 reduces 12uA why
-> MAX3232C may sink 12uA.
#else
//rGPHDAT = 0x0|(1<<6)|(1<<1)|(1<<4);
//rGPHCON = 0x0011a4;
s2440IOP->rGPHDAT = 0x0|(0<<6)|(1<<1)|(1<<4); //(1<<6)->(0<<6) reduces
12uA (MAX3232C may sink 12uA.)
s2440IOP->rGPHCON = 0x0011a4;
#endif
s2440IOP->rGPHUP = 0x0ff; // The pull up function is disabled
GPH[10:0]


//PORT J GROUP
//Ports : GPJ12 GPJ11 GPJ10 GPJ9 GPJ8 GPJ7 GPJ6 GPJ5 GPJ4
GPJ3 GPJ2 GPJ1 GPJ0
//Signal : CAMRESET CAMCLKOUT CAMHREF CAMVS CAMPCLKIN CAMD7 CAMD6 CAMD5
CAMD4 CAMD3 CAMD2 CAMD1 CAMD0
//Setting: Out Out Out Out Out Out Out Out Out
Out Out Out Out
//Binary : 01 01 01 01 01 01 01 01 01
01 01 01 01
//PU_OFF : 0 0 1 1 1 1 1 1 1 1 1
1 1

//---------------------------------------------------------------------------------------

s2440IOP->rGPJCON = 0x02aaaaaa;
s2440IOP->rGPJUP = 0x1fff; // The pull up function is disabled GPH[10:0]

//External interrupt will be falling edge triggered.
// s2440IOP->rEXTINT0 = 0x22222222; // EINT[7:0]
s2440IOP->rEXTINT0 = 0x22222224; // EINT[7:0] // charlie. button
glich
s2440IOP->rEXTINT1 = 0x22222222; // EINT[15:8]
s2440IOP->rEXTINT2 = 0x22222022; // EINT[23:16]

}





According to these how can i control portb?
Thanks.