Page 1 of 1

Mysterious issues with display over spi

Posted: Thu Jan 23, 2014 12:12 am
by Stomper85
Hi,

i have some strange issues with an lcd display (UC1701 in an DogM Display).

This is the main function of my project for an STM32F105 with an DogM Display at the SPI2 Port.

I marked breakpoints for debug with (B) in front of the line - so you can understand what happens while debugging.

Code: Select all

/*
    ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#include "ch.h"
#include "hal.h"
#include "test.h"
#include "DogM.h"

/*
 * Green LED blinker thread, times are in milliseconds.
 */
static WORKING_AREA(waUpdateDisplay, 64);


static msg_t ThUpdateDisplay(void *arg) {

  (void)arg;
  chRegSetThreadName("Display");
  while (TRUE) {


    chThdSleepMilliseconds(500);


  }
}

/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();



  UC1701Init();
  UC1701Clear();
  UC1701AddressSet(0,0);
(B) UC1701DataWrite(0xFF);



(B)  while (TRUE) {
    chThdSleepMilliseconds(500);
  }
}



So i start debugging and the first stop is at the entrypoint of the main() - pointer stops here.
I press Play/Next one time so the pointer jumps to (B) UC1701DataWrite(0xFF); as i expected.
The next time i press play/next the display should show up at least a dot or something, but nothing is on the display. But the pointer stops at (B) while (TRUE) as expected.
If i now press play/next the infinit loop should be entered and never be left, because there is no other thread than main.
But if i now press play again, the display becomes completely black anf flickers as it would be updated all the time. But the softwarepointer should never come back to where data is written to the display.
What is happening there?!

Do I have to include something in the dogm.h or dogm.c file that it is recognized by chibi-os and handled right?
I included nothing at the h file, and the following at the c file:

Code: Select all

/* Includes ------------------------------------------------------------------*/
#include "DogM.h"
#include "hal.h"


/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/
static const SPIConfig spiconfig = {NULL,
                                    GPIOA,
                                    GPIOA_DISP_CS,
                                    (SPI_CR1_BR_1 | SPI_CR1_MSTR | SPI_CR1_CPOL | SPI_CR1_CPHA)};
// | SPI_CR1_CPOL | SPI_CR1_CPHA


/* Private macro -------------------------------------------------------------*/
/* Private variables -------------------------------H--------------------------*/
uint8_t SPI_DATA_OUT[13] = {0x40,0xa1,0xc0,0xa4,0xa6,0xa2,0x2f,0x27,0x81,0x10,0xfa,0x90,0xaf};
unsigned char Ascii[]={
/*   */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,
/* ! */
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* " */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
/* # */
0x00,0x00,0x00,0xC0,0x30,0xC0,0x30,0x00,0xC8,0x39,0xCF,0x39,0x0F,0x09,0x01,0x00,
/* $ */
.
.
.


Can someone help me?

Best regards
Stomper

Re: Mysterious issues with display over spi

Posted: Thu Jan 23, 2014 9:52 am
by Giovanni
Hi,

If you need to debug make sure to compile using -O0 instead of -O2, the cursor jumping all over the place is caused by the instructions reordering and optimizations performed by the compiler.

Giovanni