Ok you should check that the mmap returns a valid pointer. If
base == MAP_FAILED then the mmap failed. This could happen because you are
not running as root - you must run as root to get access to /dev/mem
Other than that your code matches what did when I wrote code for a
fullduplex rs458 device.
Once you've set 458 fullduplex mode you go and use the interface just as if
it was an rs232 interface.
On Thu, 17 Jan 2013, khouryelie wrote:
> hello jim
> thanks for the reply
>
> > I think you need to do a byte write - otherwise you are writing
> > hex 00 to 0x22C0_0000 0x22C0_0001 0x22C0_0002 and hex 01 to 0x22C0_0002
> > when you write the integer hex 01 to 0x22C0_0000
> >
> > Just try changing Made to unsigned char *
> >
> > Don't why you have the infinite loop!
> >
>
> first the loop was part of a test i forgot to remove before posting
>
> And i did the following:
> __________________________________________________________
> #include<sys/types.h>
> #include<sys/mman.h>
> #include<stdio.h>
> #include<fcntl.h>
> #include<assert.h>
>
> int main(void)
> {
>
> int fd;
> volatile unsigned char *base;
>
> fd = open("/dev/mem", O_RDWR | O_SYNC);
>
> base = (unsigned char
> *)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x22C00000);
>
> *base = 0x01;
>
> close(fd);
>
>
> }
>
> it dosnt work,
> just i dont understand the following that i found in the manuel
>
>
> Value MSB MID LSB Mode
> 0x00 0 0 0 RS-232
> 0x01 0 0 1 Full-Duplex RS-485
> 0x02 0 1 0 -- Reserved
> 0x03 0 1 1 -- Reserved
> 0x04 1 0 0 Half-Duplex 9600 Baud
> 0x05 1 0 1 Half-Duplex 19.2Kbaud
> 0x06 1 1 0 Half-Duplex 57.6Kbaud
> 0x07 1 1 1 Half-Duplex 115.2Kbaud
>
> COM2 will default to RS-232 mode at reset (COM2 mode register = Hex 00). In
> order to switch COM2 into Full duplex RS-485 mode, the COM2 Mode register at
> 0x22C0_0000 must be set to Hex 01. In this mode, the TX drivers are always
> asserted.
>
>
>
> ISNT *base=0X01; WHAT I SHOULD DO ?
>
> what do you mean by byte write ?
>
>
> one more thing this is what they say in the MEMORY AND REGISTER MAP
>
> register address: 0x22C0_0000
> function : COM2 RS-485 control register (bits 0-2)
>
> _________________________________________________________
>
>
------------------------------------
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/
|