microsoft / pxt-maker

MakeCode target for "Maker" boards (beta)
https://maker.makecode.com/
Other
120 stars 82 forks source link

Serial UART not working with Robo HAT MM1 (custom board) #293

Closed wallarug closed 4 years ago

wallarug commented 4 years ago

Describe the bug I have been testing Serial output with the Robo HAT MM1 board (beta) and discovered the only other board that is able to send serial on pins PA16 and PA17 is the Metro M4.

The Itsybitsy M4 should also work (same processor) but does not.

I have tried excluding the serial part from the pxt.json file and manually building it / adding it to the Robo HAT MM1 through the GUI but had no luck (same results). Tried copying the same pxt.json file from the Metro M4 libs folder and using it to build a Robo HAT MM1 - still no luck.

Expected behavior Should be able to receive the string "123" on the Raspberry Pi.

Metro M4: D12 and D13: success (keeps receiving "123") Robo HAT MM1: PI_TX and PI_RX: failed (only prints "\x00\x00\x00...")

Desktop (please complete the following information):

Additional context From the testing I did last night it looks like the pins are not being configured / initialised correctly with using other boards. I could not find where they get initialised as at a high level they are all the same.

Is there anything else I can try to work out what the cause of the issue is?

wallarug commented 4 years ago

The only difference when building the board with --local is that a variable DEVICE_USB is 1 in the Robo HAT MM1 build and 0 in the Metro M4 build.

I cannot think of any reason why one would work and other correctly configured boards would not.

wallarug commented 4 years ago

Update 2

Correcting my previous statement. The Itsybitsy does work.

MakeCode/JavaScript

forever(function () {
    serial.redirect(pins.D0, pins.D1, BaudRate.BaudRate9600)
    serial.writeLine("123\r\n")
    pause(1000)
})

However, why would the custom Robo HAT MM1 not work? It still appears that the pins are not correctly being set. I get the same behaviour as if the pins are set backwards or incorrectly. When I put the ItsyBitsy M4 TX and RX backwards in the above example - I get the same behaviour as I get all the time for the Robo HAT MM1.

Below are some examples for reference to explain further what I said above.

Working Example (ItsyBitsy)

1 123\r\r\n
2 123\r\r\n
3 123\r\r\n

Not working example (Robo HAT MM1 / backwards TX+RX)

1 \x00\x00\x00\x00\x00\x00
2 \x00\x00\x00\x00\x00\x00
3 \x00\x00\x00\x00\x00\x00

Incorrect Baudrate Example (ItsyBitsy) image

wallarug commented 4 years ago

@mmoskal and @jamesadevine I noticed you guys are heavily involved with the backend CODAL work (like codal-itsybitsy-m4). Do you have any ideas on how I can get around this issue?

The pins do not seem to be initialising themselves. You ask it to be a serial pin, but it won't do it. Only with the custom board (which is calling on the itsybitsy backend).

I've been trying to work it out for days and I must just be missing something.

wallarug commented 4 years ago

Hi team,

I think we sorted this one out. Not 100% sure how but it seems to be linked to the names you give it in the board.json or config.ts file(s).

If you do not have a TX and RX pin defined (even if it is something like GPS_TX) the serial package does not work at all.

Happy to have this one closed off.