Working with Serial.mod

Newcomers to Astrobe and Oberon are welcome to ask any beginner-level questions here
Post Reply
captbill
Posts: 21
Joined: Mon Jun 16, 2014 2:57 pm

Working with Serial.mod

Post by captbill » Sun Sep 14, 2014 9:25 am

Hi,
I am trying to run the "variableBlinker" demo on my lpc1768 board and can't seem to get the serial.mod initialized. I have modified the code for the 1768. Am I missing something?
Also, do I need to call Serial.init? I get "too many parameters" with Serial.init(0,115200);

Thanks

Code: Select all

MODULE VariableBlinker;
  
IMPORT Main, MCU, Serial, SYSTEM, Timer;

PROCEDURE Run();
CONST
  (* led connected to pin P0.22 *)
  ledBit = {18};
VAR
  direction: SET;
  ch: CHAR;
  n, delay: INTEGER;
BEGIN
  (* Set led pin as output by setting the direction bit *)
  SYSTEM.GET(MCU.FIO1DIR, direction);
  SYSTEM.PUT(MCU.FIO1DIR, direction + ledBit);
  
  Serial.init(0,115200); (* returns error "too many parameters"*)
  
  ch := 0X;
  delay := 500;
  WHILE TRUE DO
    IF Serial.RxReady() & (ch = 0X) THEN 
      Serial.GetCh(ch);
      n := ORD(ch) - ORD("0");
      IF n IN {1..9} THEN delay := n * 100 END
    END;
    IF Serial.TxReady() & (ch # 0X)  THEN 
      Serial.PutCh(ch);
      ch := 0X
    END;
    SYSTEM.PUT(MCU.FIO1CLR, ledBit);
    Timer.MSecDelay(delay);
    SYSTEM.PUT(MCU.FIO1SET, ledBit);
    Timer.MSecDelay(delay)
  END
END Run;

BEGIN
  Run()
END VariableBlinker.

cfbsoftware
Site Admin
Posts: 423
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: Working with Serial.mod

Post by cfbsoftware » Sun Sep 14, 2014 12:17 pm

The first error message is usually the more important one. In this case it was:

Code: Select all

18   14 Error: undefined
Line 18, column 14 is the end of the word init. Oberon is case-sensitive, the correct name of the procedure is Init with a capital 'I'.

However, you do not need to initialise the serial port as this is already done in Main with the statement:

Code: Select all

Serial.Init(Serial.UART0, 38400);
38400 baud is the only baud rate used by the Astrobe terminal, so If you remove your call to Serial.init your program then works as expected.

NOTE: Make sure you reset the board and click on the Reset button in the Terminal window before you attempt to enter a digit.

captbill
Posts: 21
Joined: Mon Jun 16, 2014 2:57 pm

Re: Working with Serial.mod

Post by captbill » Sun Sep 14, 2014 6:38 pm

Thank you Sir.
I had not installed the mbed usb serial driver. I set it to 38400 and all is well.

Thanks

Post Reply