[En-Nut-Discussion] Ethernut3.1 RS232 DTR pin

Paul Govers egnite at paulgovers.com
Thu Dec 17 19:24:54 CET 2009


Hello Harald,

Its working now!!! i am happy!
the trick was  to set NPL_RSFON

the complete initialization is now:
 FILE *cd_rs232;
u_long baud = 9600;
u_long stopbits=1; 
u_long databits=8; 
u_long parity=0;
outb(NPL_RSCR, (inb(NPL_RSCR) & ~NPL_RSUS1E) | NPL_RSUS0E);
outb(NPL_RSCR, inb(NPL_RSCR) | NPL_RSDTR | NPL_RSRTS | NPL_RSFON);
NutRegisterDevice(&DEV_UART, 0, 0);

cd_rs232 = fopen(DEV_UART_NAME, "r+b");

_ioctl(_fileno(cd.cd_rs232), UART_SETSPEED, &baud);
_ioctl(_fileno(cd.cd_rs232), UART_SETSTOPBITS, &stopbits); 
 _ioctl(_fileno(cd.cd_rs232), UART_SETDATABITS, &databits); 
 _ioctl(_fileno(cd.cd_rs232), UART_SETPARITY, &parity);
  
Harald and Thiago thanks for your help!

Greetings
Paul 


----- Original Message ----- 
From: "Harald Kipp" <harald.kipp at egnite.de>
To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
Sent: Thursday, December 17, 2009 3:42 PM
Subject: Re: [En-Nut-Discussion] Ethernut3.1 RS232 DTR pin


> Hi Paul
> 
> Paul Govers wrote:
> 
>> i already tried to set UART_SETSTATUS with UART_DTRENABLED
>> _ioctl(_fileno(cd.cd_rs232), UART_SETSTATUS, UART_DTRENABLED);
>> but still RS232 DTR pin 0 volt :-(
> 
> and earlier
> 
>> outb(NPL_RSCR, inb(NPL_RSCR) | NPL_RSDTR);
> 
> Sorry for not jumping in earlier.
> 
> The UART of the AT91R40008 used on Ethernut 3 doesn't support hardware
> handshake. Therefore, these lines are connected to the CPLD. According to
> 
> http://www.ethernut.de/en/hardware/enut3/cpld.html
> 
> your outb() should have activated the DTR line.
> 
> Now the tricky part: You shouldn't get 0V, RS232 is either +12V or -12V.
> Theoretically. Practically it may be +7V or -7V and even +3V and -3V is
> still OK, but 0V is illegal.
> 
> The RS-232 level converter used on Ethernut 3 has an auto power-down
> feature. That means, if you remove the cable in order to measure the
> voltage, the chip will no longer detect any external voltage and will be
> shut down. In this case all outputs are indeed at 0V.
> 
> Handshake support for the Ethernut 3 CPLD had been added lately to
> Nut/OS 4.9. I assume that it is still missing in 4.8. Thus, setting
> NPL_RSDTR via the CPLD register should work and set the DTR pin to a
> negative voltage (RS-232 signals are negated).
> 
> However, if the connected device monitors DTR, it will also most likely
> monitor RTS. Try
> 
> outb(NPL_RSCR, inb(NPL_RSCR) | NPL_RSDTR | NPL_RSRTS);
> 
> You may also set NPL_RSFON, which forces the level translator to stay in
> power-on mode, even when disconnecting the cable.
> 
> 
> outb(NPL_RSCR, inb(NPL_RSCR) | NPL_RSDTR | NPL_RSRTS | NPL_RSFON);
> 
> If that still doesn't work, there may be a problem with the CPLD
> configuration. There is no known issue, and the test at egnite includes
> hardware handshake testing. You didn't upgrade the CPLD, did you?
> 
> In the worst case your hardware is broken, but that's most unlikely.
> RS-232 interfaces are very robust.
> 
> Another possibility is to use special cable connections
> 
> http://www.ethernut.de/en/documents/rs232primer.html
> 
> Are you using the same cable for the PC-Heater connection and the
> Ethernut-Heater connection?
> 
> Harald
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion



More information about the En-Nut-Discussion mailing list