CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Time padding on RS232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cylence



Joined: 21 Feb 2006
Posts: 3
Location: Planet Earth

View user's profile Send private message

Time padding on RS232
PostPosted: Tue Feb 21, 2006 10:24 am     Reply with quote

I am trying to simulate a particular serial protocol (DMX512, used by stage lighting equipment) using the USART
of the PIC16F877. The bps speed is at 250KHz (1 bit = 4u sec. wide).
I need to manually craft the packets so they can be 100% compatible with the equipment.
Obviously the idle state for the serial communication is always a "high" state.
I need to put the level to a low state for at least 88 uSec (20 bits), this is
the "break code" of the packet according to the DMX protocol. Here is a simplified sample of my code to acheive this :

void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
do
{
output_C(0x0); //low state
delay_us(128); //Break code delay.
putc(0xA); //sample data
}
while(1);
}

in my ".h" I have the following :

#include <16F877.h>
#device ICD=TRUE
#device adc=8
#fuses NOWDT,HS, NOPUT, NOPROTECT, BROWNOUT, LVP, NOCPD, NOWRT, DEBUG
#use delay(clock=20000000)
#use rs232(baud=250000,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

Note that I need to programm a 128 usec delay in order to acheive an actual 88 usec delay at the output, wich is the
execution latency (around 40 usec).
My problem is that the USART does my "time padding" but not at the correct state. I need it to be at a low state for that
period of time but the USART always outputs it at 1.
Can someone let me know how to override this or even tell me if its feasable to override the state of the serial pin while
idling or a better way to acheive this ? Your help would be greatly appreciated.
Thank you.
_________________
Gravity Works.
cylence



Joined: 21 Feb 2006
Posts: 3
Location: Planet Earth

View user's profile Send private message

PostPosted: Tue Feb 21, 2006 10:47 am     Reply with quote

Yes, I am actually using a 75176 transceiver at the output of my PIC USART.
Transceiver works well, my problem is with the logic state of my time padding.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Feb 21, 2006 10:59 am     Reply with quote

There are several ways to do this. Here is a couple:

1. You can take control of the TX pin away from the UART and do the break yourself.

2. You can change to baud rate of the UART to a lower rate and send a 0x00 character. Once the character has gone you can then change the rate back again.

Quote:

Note that I need to programm a 128 usec delay in order to acheive an actual 88 usec delay at the output, wich is the execution latency (around 40 usec).


This does not make sense - I assume you have missed something in the explanation. For example, has this been done to enable the previous character to be serialized out?

If so then the way to do this is monitor the state of the TRMT bit in the TXSTA register to wait until the Transmit Shift Register (TSR) is empty. When empty then set the output low, delay 88us, set the output high.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
cylence



Joined: 21 Feb 2006
Posts: 3
Location: Planet Earth

View user's profile Send private message

PostPosted: Tue Feb 21, 2006 11:49 am     Reply with quote

I'm guessing I should use the "SET_UART_SPEED()" command to reduce the transmit speed, right ?
Also how can I take the controll away from the UART ? Do you have some example code ?

As for my latency explanation, I didn't program this to serialize a previous character.
I have probably misunderstood some concepts. I simply noticed on my logic analyser that when I tried to
output a level to a certain amount of time, the result displayed was always shorter than the time
programmed. So I streched it to 128 usec to be able to see a delay of 88 usec on my logic analyser. This is surely not
the best way to acheive it, but its all I've came up with so far.

Thanx in advance ;)
Guest








Re: Time padding on RS232
PostPosted: Tue Mar 14, 2006 12:02 am     Reply with quote

there r a dmx decoder:dm118

http://www.freeweb.com.tw/sd/upload/product/File/Product/DM118X%20_SD.pdf


http://www.skylinedynamics.com/
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group