PDA

View Full Version : SCI0 problem


cwkoehler
10-05-06, 09:56 PM
Hello all,
I am trying to receive a single character on the SCI0, test the character and respond accordingly. Using the code below I am not able to send, test and respond to a single character. I have to press the character dozens of times or hold down the character before I get any response. I have tried buffers to no avail. Any insight would be appreciated. Thanks in advance for your reply


( Syringeability Prototype – DSP56F805 Controller
( Programmer: Chris Koehler
( Date: 10/1/06

SCRUB
HEX

VARIABLE RXCHAR EEWORD
VARIABLE FSR EEWORD
VARIABLE ACTUATOR_DIR EEWORD

: LED-INIT
GRNLED OFF
YELLED OFF
REDLED OFF
; EEWORD

: GET-CHAR SCI0 RX RXCHAR !
YELLED ON ; EEWORD

: GET-ADC1 FSR ADC1 ANALOGIN ! ; EEWORD

: PWM-INIT
PWMA0 INDEPENDENT
PWMA1 INDEPENDENT
4E2 PWMA0 PWM-PERIOD
; EEWORD

: EXTEND
3333 PWMA0 PWM-OUT
PA0 ON
; EEWORD

: RETRACT
CCCC PWMA0 PWM-OUT
PA0 OFF
; EEWORD

: TURNOFF
PWMA0 OFF
PA0 OFF
HEX
; EEWORD

MACHINE SERIAL_IO EEWORD
ON-MACHINE SERIAL_IO
APPEND-STATE SER-IN EEWORD
APPEND-STATE MTR-MIND EEWORD
APPEND-STATE SER-OUT EEWORD

IN-STATE
SER-IN
CONDITION
SCI0 RX?
CAUSES
GET-CHAR
THEN-STATE
MTR-MIND
TO-HAPPEN

IN-STATE
MTR-MIND
CONDITION
RXCHAR C@ 30 =
CAUSES
EXTEND
THEN-STATE
SER-OUT
TO-HAPPEN

IN-STATE
MTR-MIND
CONDITION
RXCHAR C@ 31 =
CAUSES
RETRACT
THEN-STATE
SER-OUT
TO-HAPPEN

IN-STATE
MTR-MIND
CONDITION
RXCHAR C@ 30 < RXCHAR C@ 31 > OR
CAUSES
TURNOFF
THEN-STATE
SER-OUT
TO-HAPPEN

IN-STATE
SER-OUT
CONDITION
CAUSES
GET-ADC1
THEN-STATE
SER-IN
TO-HAPPEN


: STARTUP
PWM-INIT
LED-INIT
SER-IN SET-STATE
INSTALL SERIAL_IO
EVERY FFFF CYCLES SCHEDULE-RUNS SERIAL_IO
; EEWORD




Chris Koehler

Dave
10-06-06, 10:28 AM
Hi Chris,

Here's a few things that might help.

It appears that the GET-CHAR word is looking for a charecter, and therefore should have a C! (C-store) rather than a ! (store).

GET-ADC1 should have the FSR variable addressed after a value has been retrieved by ADC1 ANALOGIN, so the store goes to where it is needed.
: GET-ADC1 ADC1 ANALOGIN FSR ! ; EEWORD

In PWM-INIT, setting both of the pair of PWMA0 and PWMA1 as INDEPENDENT is redundant, setting one is supposed to set the other, but doing both should not cause a problem.

And the last code paragraph before machine initialization, where the test for the state of SER-OUT, there is no CONDITION. I'm not sure what this would cause, but guessing it might always test true and go back to SER-IN, or might lock up.

A final note, in STARTUP, INSTALL SERIAL_IO and EVERY FFFF CYCLES SCHEDULE-RUNS SERIAL_IO is redundant. Using INSTALL also would require using ISOMAX-START to begin the processing of the machine, where EVERY FFFF CYCLES SCHEDULE-RUNS SERIAL_IO does both installing of the machine and the beginning of the clocking through the machine.

nmitech
10-06-06, 10:55 AM
1. Add the serial buffer.
2. Don't forget to ended with IN-EE for every IN-STATE transition.
3. Don't leave the CONDITION blank. This can create problem with unpredictable data on stack.


SCRUB
HEX

( create a receiving buffer to hold 80 serial characters )
HERE 80 4 + ALLOT CONSTANT RBUFF EEWORD
RBUFF 80 4 + SCI0 RXBUFFER

( as well as for the transmitting buffer )
HERE 80 4 + ALLOT CONSTANT TBUFF EEWORD
TBUFF 80 4 + SCI0 TXBUFFER

VARIABLE RXCHAR EEWORD
VARIABLE FSR EEWORD
VARIABLE ACTUATOR_DIR EEWORD
......
......
......

IN-STATE
....
CONDITION
( put something here, or 1 . Don't leave this blank )
CAUSES
.....
THEN-STATE
......
TO-HAPPEN
IN-EE


: STARTUP
RBUFF 80 4 + SCI0 RXBUFFER
TBUFF 80 4 + SCI0 TXBUFFER
PWM-INIT
LED-INIT
SER-IN SET-STATE
INSTALL SERIAL_IO
EVERY FFFF CYCLES SCHEDULE-RUNS SERIAL_IO
; EEWORD

cwkoehler
10-17-06, 04:54 PM
Sorry for the late 'Thanks' reply
Things are working now given the implementation of your suggestions


Thanks Chris