This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Debugging stops at particular function

Hello,

I wrote the code for HT1632 using SPI Protocol 

while debugging when it comes to below function it will stop debugging

HT1632_5X21_init( LED_MAX_DISPLAY_X, LED_MAX_DISPLAY_Y); 

is this correct way for using SPI transfer

void HT1632_5X21_init(uint8_t aneDevices, uint8_t twoDevices)
{

    uint8_t i;
    numXDevices = aneDevices;
    //aneMax=31;
    aneMax = 32 * numXDevices-1;
    numYDevices = twoDevices;                   
    twoMax = 8 * numYDevices-1;
    //twoMax = 7;
 
    numDevices = numXDevices * numYDevices;

    static uint8_t      m_tx_buf[9] = {HT1632_ID_CMD,HT1632_CMD_SYSDIS,HT1632_CMD_COMS10,HT1632_CMD_MSTMD,HT1632_CMD_SYSON,HT1632_CMD_LEDON,HT1632_CMD_PWM | 0x0c,0,1}; /**< TX buffer. */
    static const uint8_t m_length = sizeof(m_tx_buf);
    static uint8_t       m_rx_buf[sizeof(m_tx_buf)+1]; 
    memset(s_rx_buf, 0, s_length);
    APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&spis, s_tx_buf, s_length, s_rx_buf, s_length));
    memset(m_rx_buf, 0, m_length);
    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));
  
    cursorX = 0;
    cursorY = 0;
    for ( i=0; i<64; i++)
       HT1632_LedMatrix_senddata(chipno,i,0);

}


 void HT1632_LedMatrix_senddata (uint8_t chipno, uint8_t i, uint8_t data )
{
        
    uint8_t   n_tx_buf[3] = {HT1632_ID_WR, i,0};           /**< TX buffer. */
    static const uint8_t  n_length = sizeof(n_tx_buf);
    static uint8_t       n_rx_buf[sizeof(n_tx_buf)+1];    /**< RX buffer. */
 
    memset(t_rx_buf, 0, t_length);
    APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&spis, t_tx_buf, t_length, t_rx_buf, t_length));
    memset(n_rx_buf, 0, n_length);
    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, n_tx_buf, n_length, n_rx_buf, n_length));

  
  //nrf_delay_ms(10);
}

void putString(int ane, int two, char *str) {
    cursorX = ane;
    cursorY = two;
    while(*str!='\0') {
        putChar( cursorX, two, *str++ );
        cursorX += 6;
    }
}

int putChar(int ane, int two, char c) {
  // fonts defined for ascii 32 and beyond (index 0 in font array is ascii 32);
  // CGRAM characters are in range 0 to 15 with 8-15 being repeat of 0-7
  // note we force y to be modulo 8 - we do not support writing character to partial y values.
 
  uint8_t charIndex;
  uint8_t colData;
  uint8_t numCols;
  uint8_t chipno;
  uint8_t addr;
  uint8_t colsLeft = 0;        // cols that didn't fit
 
  if( c > 15 )
    {
    // Regular characters
    // replace undisplayable characters with blank;
    if (c < 32 || c > 126)
     {
            charIndex = 0;
    }
     else
      {
            charIndex = c - 32;
    }
 
    // move character definition, pixel by pixel, onto the display;
    // fonts are defined as one byte per col;
      numCols=smallFont[charIndex][6];   // get the number of columns this character uses
      for (uint8_t col=0; col<numCols; col++) {
            colData = smallFont[charIndex][col];
       // chipno = chip_number(x,y);
        addr = chip_byte_address(ane,two); // compute which memory byte this is in
        if (ane <= aneMax && two <= twoMax) {
            shadowram[(addr>>1)+32*chipno] = colData;
            sendcol(chipno,addr,colData);
            ane++;
        } else {
            colsLeft++;
        }
    }
  } else {
    // CGRAM Characters
    charIndex = c & 0x07;       // Only low 3 bits count
    numCols=cgram[charIndex][0];    // get the number of columns this character uses
    // fonts are defined as one byte per col;
        for (uint8_t col=1; col<=numCols; col++) {
            colData = cgram[charIndex][col];
            //chipno=1;
        //chipno = chip_number(x,y);
        addr = chip_byte_address(ane,two); // compute which memory byte this is in
        if (ane <= aneMax && two <= twoMax) {
            shadowram[(addr>>1)+32*chipno] = colData;
            sendcol(chipno,addr,colData);
            ane++;
        } else {
            colsLeft++;
        }
    }
  }
 
  cursorX = ane;
  cursorY = two;
 //clear();
  return colsLeft;
}
void sendcol( uint8_t chipno, uint8_t address, uint8_t data)
{

    uint8_t   o_tx_buf[3] = {HT1632_ID_WR,address,data};  
    static const uint8_t o_length = sizeof(o_tx_buf);
    static uint8_t       o_rx_buf[sizeof(o_tx_buf)+1];    /**< RX buffer. */
  
    memset(u_rx_buf, 0, u_length);
   APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&spis, u_tx_buf, u_length, u_rx_buf, u_length));
    memset(o_rx_buf, 0, o_length);
 APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, o_tx_buf, o_length, o_rx_buf, o_length));
 
}
 
//void clear()
//{
//
//static uint8_t p_tx_buf[3]={HT1632_ID_WR,0x00};
//static const uint8_t p_length = sizeof(p_tx_buf);
//static uint8_t       p_rx_buf[sizeof(p_tx_buf)+1];    /**< RX buffer. */
//APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, p_tx_buf, p_length, p_rx_buf, p_length));
//
//  cursorX = 0;
//  cursorY = 0;
//}

 int main()
 {
    printf("HT1632 Driver started.");
    bsp_board_init(BSP_INIT_LEDS);
    //unsigned char str[]={"technical"};
    unsigned char str2[]={"welcome"}; 
    spi_init();
   // NRF_POWER->TASKS_CONSTLAT = 1;
    spis_init();
    
    HT1632_5X21_init( LED_MAX_DISPLAY_X, LED_MAX_DISPLAY_Y);
    putString(0,0,str2);
    while(1)
    {
  __WFE();
    }
 
 }

what is wrong with HT1632_5X21_init( LED_MAX_DISPLAY_X, LED_MAX_DISPLAY_Y);  and  putString(0,0,str2); functions

thanks

learn

Parents Reply
  • Still hard to understand what's actually happening - remember that we can't see you, or your bench, or what you are actually doing, or what is actually happening.

    Remote debugging is hard!

    Do you have teachers / supervisors / colleagues locally who could help you?

    while debugging using STEP OVER(F10).

    Instead of Step-Over, try Step-Into - this should, at least, help to narrow down where the problem is occurring.

    What board are you using?

    You aren't using the debugger SWD lines as SPI, or anything else, are you ... ?

Children
No Data
Related