Trouble getting correct format to print on 32028

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Nora
    Member
    • Oct 2008
    • 60

    Trouble getting correct format to print on 32028

    Hello and happy holidays all!I'm using 4DGL v2.3 beta and pmmc 1.6I've got a 32028-P1T communicating with a PIC 18F452 and using Hyperterminal
    inbetween to debug.
    I have the 32028 connected RX to PIC TX and TX to PIC RX. No resisters.
    Hyperterminal is also connected to the PIC at the same time via my laptop's USB-->serial converter cable.
    I'm sending a number 0x87 from the 32028 to the PIC and asking the PIC to send it back. The number gets as far as coming back to HT, since HT prints it over and over. Since the RX and TX lines are the same on both HT and 32028, I would think they'd print the same thing.
    But they don't. The 320238 prints "FE" over and over every newline.
    Obviously an operator error, but this operator is clueless.
    Here is the 32028 code:
    Code:
    func main()var ch,num;setbaud(6);gfx_Cls();txt_Set(FONT_SIZE, FONT2);print ("Serial I/O Test\n");// looprepeatch := serin();num := 0x87;serout(num);pause(990);if (ch != -1)print("\n",[HEX2]ch );pause(990);         // value in millisecendifforeverendfunc
    Here is the PIC code snip:
    Code:
    int ch;void main(){delay_ms(1000);while(1){if (kbhit()){ch = getc();delay_ms(1040);printf("\n %x",ch); // send msg}else{delay_ms(300);printf("\n NO"); // send msgdelay_ms(300);}}}
    I'd also like to know how to print a string. In the PIC code, if I substitute "HELLO" for printf("\n %x",ch)
    ; , and have the 32028 receive it with print("\n",[STR]ch )
    ;
    I get garbage on the 32028, but "HELLO" on the Hyperterminal.

    Thanks!
    Nora
  • mvandere
    Senior Member
    • Nov 2007
    • 134

    #2


    Hmm, where to start...

    Just because Hyperterm (or should I say the serial interface on you PC) can interpret what it is seeing correctly doesn't mean the 32028 is 'wrong' in its interpretation, check the various posts about resistors again and see if you can get a feel for what is truly required.

    I can see you have the 32028 set to 9600 baud, are the other two set to the same speed?

    You have no 'autobaud' lockin code. This code is not just for the heck of it, whilst some serial port's seem to lock in correctly without any problems others seem to easily get confused and 'lock in' incorrectly. The 'U' character is a good lockin character as it has a good mix of 0s and 1s.
    So, the fact that you are getting 0x87 consistently interpreted as 0xFE would get me firstly checking the baud rates, and secondly checking resistors (as you are getting too many 1s), thirdly the autobaud.


    Once you fix that the 'Hello' will work correctly

    Comment

    • RGV250
      Member
      • Sep 2008
      • 55

      #3


      Hi,
      I may be wrong but the fact that RS232 is point to point and you have 3 devices connected may mess things up.
      Have you tried just Hyperterminal and the display, I would go right back to basics and just have the display show the ascii value first. At least after that you know the comms will be right to the display.

      Regards,
      bobby

      Comment

      • steve4690
        Member
        • Sep 2008
        • 83

        #4


        Having two RS232 TXs connected to one RX will cause problems as TX is driven high when not in use, and since you'll be transmitting down only one of the TXs at a time the other will be interfering.

        Steve

        Comment

        • Nora
          Member
          • Oct 2008
          • 60

          #5


          Thanks for all the responses!
          Yes, all bauds are set to 9600, no parity, 8 bit, hardware flow control None.
          I had originally had a "U" in there and no change in result. Thanks Steve, I didn't realize that TX is driven high in its unused position.
          OK I will:
          1.Put the U back
          2.Try just Hyperterminal and 32028 display
          I did these two things. With the following small code (baud still = 9600), I sent "Hello" to hyperterminal. Nothing else connected to either the display or to HT.
          I get garbage on HT, but "Hello" as expected on display.
          HTML Code:
              repeat  
          pause(990); 
          print("Hello");
          forever 
          Re: resisters
          In the circuit diagram in the 3202X-P1 manual, page 8, it is shown two current
          limiting resisters on TX and RX and also a pullup on RX
          So my conclusion on getting a feel for the resisters...do nothing.
          Please clarify if this is incorrect!

          Thanks!
          Nora

          Comment

          • Nora
            Member
            • Oct 2008
            • 60

            #6


            When I put the SPE 4DGL code into the display and give a "U" from HT, the splash screen is bypassed.
            The "ACK" I receive back is a garbage character that isn't on the table
            http://www.asciitable.com/ but it is a character back.

            When I change the ACK to 0x4E, I get back (in response to "U" before Splash Screen loads), an "N" on HT.
            So HT is working with the display.

            Comment

            • Nora
              Member
              • Oct 2008
              • 60

              #7
              Working!
              The trouble turned out to mostly be a formatting problem. I was able to get the two controllers to talk once I told the 4DGL to serout('N').
              Works OK even with HT connected at the same time....but I agree with Steve, not a good idea for troubleshooting.
              I used a bunch of the SPE code to make this work.
              4DGL code here:
              Code:
              #platform "uOLED-32028-P1T"#CONST num 0x4Efunc SC_UnlockDetect(var inTimeOut)var rx, serIsValid, timeOut;rx := 0;serIsValid := 0;timeOut := inTimeOut;sys_SetTimer(TIMER0, inTimeOut);repeatrx := serin();if (rx == 'U') serIsValid := 1; //if "rx" is U, then serIsValid =1until (sys_GetTimer(TIMER0) == 0 || serIsValid)if (serIsValid)pause(100);  // added delay 13112008serout(num);endifreturn serIsValid;endfuncfunc main()var ch;gfx_Cls();setbaud(6);repeatif (SC_UnlockDetect(5000) == 0)print("Hello world");while (SC_UnlockDetect(500) == 0);gfx_Cls();serout('N');endifforeverwhile(1);endfunc
              And PIC code here:
              Code:
              #use RS232 (baud = 9600, xmit= PIN_C6, rcv = PIN_C7,BITS=8,PARITY=N,errors)char ch,num;void main(){output_low(PIN_B5);delay_ms(1000);num = 'N';while(true){printf("U");ch = getc();if (ch == 'N'){//delay_ms(1000);output_high(PIN_B5);printf("%c YES",ch); // send msg}else{delay_ms(300);printf("\n NO"); // send msgoutput_low(PIN_B5);delay_ms(300);}}}


              Comment

              Working...
              X