Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Gameduino and FlexCAN library issue

  1. #1
    Junior Member
    Join Date
    Jun 2018
    Posts
    3

    Gameduino and FlexCAN library issue

    Hi everyone,

    I'm having an issue with my HotMCU display running Lightcalamar's GD23Z library along with the flexCAN library. It's being run on a Teensy 3.5.

    With my current code, the display works fine with a potentiometer connected to the input, the readings update pretty fast. If I add in the flexCAN code, the can bus readings are really slow, like 30 seconds to update. If I print the data to the serial monitor, it's also slow. The data is being fed via CAN bus from a Megasquirt 2 ECU.

    Now if I cut out the GD23Z code and just run the flexCAN code, the serial monitor prints the data instantly so it's leading me to believe that the GD code is causing the lag. I'm using the GD.finish(); command at the end of the code and I've tried GD.flush(); with the same results.

    Also, unrelated issue but I've noticed that if I run a 800x480 jpg as a background, it causes the gauges and numbers to not run as smoothly as it does with just a solid color background. The display still works but I would love to have it be smooth.

    Here's the sample of my code,

    #include <SPI.h>
    #include <GD23Z.h>
    #include <FlexCAN.h>

    static CAN_message_t rxmsg;

    File loadScreen;

    SdFatSdioEX SD;

    int analogPIN = 33;
    int val = 0;
    int KPA = 0;

    float MAP, RPM, CLT, TPS, SPKADV, AFR, BATTV, IAT;


    void setup() {
    Can0.begin(500000);
    Serial.begin(9600);
    Serial4.begin(115200);

    pinMode(SD_PIN, OUTPUT);
    digitalWrite(SD_PIN, HIGH);
    delay(20);
    digitalWrite(SD_PIN, LOW);
    delay(20);
    digitalWrite(SD_PIN, HIGH);
    delay(20);

    GD.begin(1);
    SD.begin();

    }

    void loop() {

    GD.Clear();
    loadScreen = SD.open("main2.jpg");
    GD.cmd_loadimage(0, 0);
    GD.loadSDIO(loadScreen);
    GD.Begin(BITMAPS);
    GD.Vertex2ii(0, 0);

    GD.ColorRGB(0xFFFFFF);
    GD.cmd_number(240,28,31,OPT_RIGHTX,(MAP/10));
    GD.cmd_number(240,75,31,OPT_RIGHTX,(IAT/10));
    GD.cmd_number(240,125,31,OPT_RIGHTX,KPA);

    GD.swap();
    GD.finish();

    canData();

    Serial.println(IAT);

    }

    void canData() {
    if ( Can0.read(rxmsg) ) {
    switch (rxmsg.id) { // Using IDs from 1512 as Megasquirt CAN broadcast frames for Simplified Dash Broadcasting.
    // EAch frame represents a data group http://www.msextra.com/doc/pdf/Megas..._Broadcast.pdf
    case 1512:
    MAP = (float)(word(rxmsg.buf[0], rxmsg.buf[1]));
    //RPM = (float)(word(rxmsg.buf[2], rxmsg.buf[3]));
    CLT = (float)(word(rxmsg.buf[4], rxmsg.buf[5]));
    TPS = (float)(word(rxmsg.buf[6], rxmsg.buf[7]));
    //CLT = FtoC(CLT / 10);
    break;
    case 1513:
    IAT = (float)(word(rxmsg.buf[4], rxmsg.buf[5]));
    //SPKADV = (float)(word(rxmsg.buf[6], rxmsg.buf[6]));
    break;
    case 1514:
    AFR = (float)(word(0x00, rxmsg.buf[1]));
    break;
    case 1515:
    //BATTV = (float)(word(rxmsg.buf[0], rxmsg.buf[1]));
    //generic1 = (float)(word(rxmsg.buf[2], rxmsg.buf[3]));
    //generic2 = (float)(word(rxmsg.buf[4], rxmsg.buf[5]));
    break;
    }
    }
    }

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    2,738
    sounds like the display is taking more priority, have you tried setting flexcan to a higher priority?

  3. #3
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    2,738
    NVIC_SET_PRIORITY(IRQ_CAN0_MESSAGE,0);
    NVIC_ENABLE_PRIORITY(IRQ_CAN0_MESSAGE);

    try adding that AFTER can0.begin...

    i havnt check the display library, but if its disabling interrupts that can be a different issue

  4. #4
    Junior Member
    Join Date
    Jun 2018
    Posts
    3
    I will give that a try and report back...thanks!

  5. #5
    Junior Member
    Join Date
    Jun 2018
    Posts
    3
    I'm getting an error "'NVIC_ENABLE_PRIORITY' was not declared in this scope". If I comment that line out and just use "NVIC_SET_PRIORITY(IRQ_CAN0_MESSAGE,0);", I get the same results.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •