Main Site Documentation

CAN on UC5550 on UCM Dev Board


#1

I am trying communicate via CAN using a UC5550 on a UCM DEV board (rev. E) but have been unsuccessful. I am new to TinyCLR and embedded development, in general. I got the bootloader, firmware and sample programs loaded successfully. Have there been any others that have been successful in CAN communication with this hardware? I have wired the UCM board from CAN A port to a USB to CAN converter in my PC that I have verified is working correctly. I have tried sending command from PC to UCM but I get no response on the Visual Studio console window.

I am using the code in the website tutorials sections, CAN sub-section. I have modified the code below based on different hardware than the example code. Is there anything obvious I am doing wrong?

       var downButton = GpioController.GetDefault().OpenPin(0);
    
        downButton.SetDriveMode(GpioPinDriveMode.InputPullUp);

        var can = CanController.FromId(UC5550.CanBus.Can1);

How do I determine the openPin # for the hardware I have if I want to put GPIO PinC on the dev board low?

Do I need I need to jumper the CAN termination?

Is there any other detailed TinyCLR API documentation for CAN other than the tutorial?

Lastly, now Windows is not recognizing my UC5550 board via USB. Not sure if something bad has happened. Any ideas on recovery?

Sorry for all the questions. Thanks for your help.


#2

You have multiple questions so it is hard to help. Let’s start with getting your hardware functioning again. Do you have a blinking led going?


#3

For now, ignore the hardware not functioning issue. That is something that happened long after I was not able to get any CAN communication working.

My main focus is getting CAN communication working. The example online code is for a G120E and I am using a UC5550 with UCM dev board. What are your recommendations, code-wise, for CAN communication testing. How do I determine the openPin # for the hardware I have if I want to put GPIO PinC on the dev board low?


#4

There is no “open pin” for CAN. Please see this http://docs.ghielectronics.com/software/tinyclr/tutorials/can.html

We use a button in the demo and that is the GPIO but beside that CAN does not need GPIO.

I would say start with a simple example that sends a CAN message once every second. Then check for that message on your other device. Do not forget to have a termination resistor on your wires.


#5

I would like to use the same concept as in the demo where one puts a digital input low to send a can message (rather than send every x seconds). I am using the UCM dev board and would like to use GPIO C. So my question is basically more around pin mapping. For the code below, what is the correct pin Id # for GPIO C that I would use? Documentation on the UCM and UC5550 is unclear.

var downButton = GpioController.GetDefault().OpenPin(0);


#6

Regarding the pin question, you’ll want to use the GHIElectronics.TinyCLR.Pins.UCM library. You’ll then call GHIElectronics.TinyCLR.Pins.UCMStandard.SetModel(…) at the start of your program. After that, you can pass GHIElectronics.TinyCLR.Pins.UCMStandard.GpioPin.C to OpenPin.


#7

No expert but I think this is what you want.
The Developer board LED by the IRQ A button
Using a UC5550

Review the schematic for the UC5550. It shows the pin ID for every pin

GPIO C LED
The signal will be seen on Header B - Pin GPIO C

int time_ms = 1000;
GpioPin led_GPIOC = GpioController.GetDefault.OpenPin(UC5550.GpioPin.PG3);
led_GPIOC.SetDriveMode(GpioPinDriveMode.Output);

// Blink GPIO C LED by the IRQ A button
for (int i = 1; i <= 4; i++)
{
Debug.WriteLine("TinyCLRApplication test " + i.ToString());
led_GPIOC.Write(GpioPinValue.High);
Thread.Sleep(time_ms);
led_GPIOC.Write(GpioPinValue.Low);
Thread.Sleep(time_ms);
}

Header B GPIO
GPIO.C Pin 64 PG3
GPIO.D Pin 66 PG6
GPIO.E Pin 67 PG7
GPIO.F Pin 68 PH4
GPIO.G Pin 69 PI0
GPIO.H Pin 92 PA1
GPIO.I Pin 119 PA2
GPIO.J Pin 122 PA7
GPIO.K Pin 132 PC4
GPIO.L Pin 136 PC5

Buttons
Reset Pin 187
IRQ A Pin 57 P18
IRQ B Pin 58 PI11
IRQ C Pin 59 PH14
IRQ D Pin 61 PH15
SYS/Boot A Pin 107
SYS/Boot B Pin 134 PB2
SYS/Boot C Pin 111 PI1
SYS/Boot D Pin 135 PI3


#8

Thanks for this information and the sample LED program. I can now see where you got it and it got me back up and running. Thanks!


#9

Any recommendations for the CAN timing parameters for the UC5550 (see list below)? I am getting the following text on the console output : Error GHIElectronics.TinyCLR.Devices.Can.ErrorReceivedEventArgs when I try to send. I have tried different CAN timing parameters and looked at various web calculators but have been unsuccessful. I will be communicating with a device that is set to 125 kbits/sec. Thanks for any input.

        var propagation = 0;
        var phase1 = 7;
        var phase2 = 4;
        var baudratePrescaler = 20;
        var synchronizationJumpWidth = 1;
        var useMultiBitSampling = true;

#10

Look like that values for 225kbit, not 125kbit

try

controller.SetBitTiming(new GHIElectronics.TinyCLR.Devices.Can.CanBitTiming(0, 7, 8, 27, 1, false));


#11

Thank you for the insight and information. I know have the CAN communications working properly!