We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to simulate a serial input from the keyboard PC. I have used the serial input window and when i press a key, uVision simulate a serial input, but.., how can i enter a several characters together?. The problem is tha it can't be delays between characters in the input serial interface, so i must resolve it. Thanks
I assume you want to simulate a serial message as you may receive from another computer at a given baudrate. If so, then try using a signal function. There is an example of this on page 93 in the "dScope for Windows Users Guide" but it is not as clear as it could be. First, consider if you need to simulate the actual timing of the characters coming in. Remember, characters will arrive at a different rate for different baudrates. If you want to simulate this timing, you need to set STIME=1 and then you need to instruct the signal function how long to delay between each character using the twatch command. If you're not concerned about this timing, set STIME=0 and don't worry about the twatch statements in the example below. The formula for calculating the arrival time of characters at various baudrates is (XTAL / clocks per machine cycle) / (BAUDRATE / bits transmitted per character). Clocks per machine cycle is normally 12 although the Dallas chips can be set up to operate at 4 clocks per machine cycle. Bits transmitted per character is 10 for asynchronous mode -- one start bit, eight data bits, and one stop bit. The following example will set up a pushbutton in a toolbox window named "Send Message". When pressed, it will send the message. In this example, the message is a Modbus "Read Status" command but you can change this example to send any message you wish.
STIME=1 /* Simulate serial timing */ XTAL = 11059200 /* Specify clock frequency */ define button "Send Message","send ()" /* Set up pushbutton */ DEFINE INT baud /* Define baudrate */ baud = 28800 /* change as needed */ signal void send (void) { SIN = 0x11; /* Send first character */ twatch ((xtal/12)/(baud/10)); /* Delay for one character time */ SIN = 0x02; /* Send second character */ twatch ((xtal/12)/(baud/10)); /* Delay for one character time */ SIN = 0x00; /* and so on */ twatch ((xtal/12)/(baud/10)); SIN = 0x00; twatch ((xtal/12)/(baud/10)); SIN = 0x00; twatch ((xtal/12)/(baud/10)); SIN = 0x20; twatch ((xtal/12)/(baud/10)); SIN = 0x7B; twatch ((xtal/12)/(baud/10)); SIN = 0x42; twatch ((xtal/12)/(baud/10)); }