Ok I've snipped stuff out. Also have you tested that you are actually
addressing the DIO interface? Have you hooked up wires from 3.3v and ground
to various DIO pins and then checked that your read code actually gets
the right values?
Comments below...
On Wed, 3 Nov 2010, yavin229 wrote:
>
> #define SSPCR0 0x808a0000
> #define base 0x808a0000
>
> int fd,diobits,diobits_post_change, dio_direction_bits,
> dio_direction_bits_post_change;
>
> int main ()
> {
> volatile unsigned long int *memloc;
>
> fd = open("/dev/mem", O_RDWR|O_SYNC);
>
> if (fd == -1){
> perror("open(/dev/mem):");
> return 0;
> }
>
> memloc = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, MEMLOC);
> assert(memloc != MAP_FAILED);
>
> diobits = PEEK8( (unsigned long)(memloc + 0x04));
You are adding 4 to an int pointer. The compiler knows this is an int and
assumes you want the 4th int after so in bytes, this is the same as
memloc+16. At this address is the LCD interface byte ddr register.
Either make your pointer an unsigned char * so that offsets are in bytes,
you are accessing a single byte anyway, or use memloc+1 here.
You can check this by printing the addresses using a printf to double
check.
Jim
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|