CB3.0 F100 - I2C issues

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: CB3.0 F100 - I2C issues

Postby Giovanni » Mon Oct 07, 2013 8:17 pm

All the F1-specific drivers are still untested, it is possible there are problems originated during the porting.

I have still to run the applications under ./testhal/STM32F1xx so be careful.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: CB3.0 F100 - I2C issues

Postby Giovanni » Tue Oct 08, 2013 10:31 am

Hi,

I fixed a problem that could have caused that panic, could you give it another try?

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: CB3.0 F100 - I2C issues

Postby Giovanni » Tue Oct 08, 2013 11:08 am

Also fixed another problem in the DMA handler affecting all drivers using DMA.

Everything should be OK now.

Giovanni

pito
Posts: 199
Joined: Sun Nov 06, 2011 3:54 pm

Re: CB3.0 F100 - I2C issues

Postby pito » Tue Oct 08, 2013 7:13 pm

It started to work somehow, but:
1. when I2C stuff enabled it crashes in an unhandled exception (I will investigate)
2. getting compile error: 'RDY_OK' undeclared here (not in a function)
usually returned by i2cMasterTransmitTimeout() - is being lost somewhere, so I have to def it in my source as 0
3. even set #define CH_CFG_ST_RESOLUTION 32
the chVTGetSystemTimeX(); counts 16bit.. chTimeNow() worked fine 32bit
4. what is the meaning of:
#define CH_CFG_RTC_FREQUENCY 72000000
plz?
Last edited by pito on Tue Oct 08, 2013 7:27 pm, edited 1 time in total.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: CB3.0 F100 - I2C issues

Postby Giovanni » Tue Oct 08, 2013 7:18 pm

RDY_OK has been renamed to MSG_OK, CH_CFG_RTC_FREQUENCY is the frequency of the realtime counter on the F4 it should be 168000000 but it is not really important unless using the RTC-related time conversion macros.

Giovanni

pito
Posts: 199
Joined: Sun Nov 06, 2011 3:54 pm

Re: CB3.0 F100 - I2C issues

Postby pito » Tue Oct 08, 2013 7:38 pm

I have a task, which does:

Code: Select all

static THD_WORKING_AREA (waThread1, 128);
static THD_FUNCTION (Thread1, arg) {

  (void)arg;
  chRegSetThreadName("counter");

  // Time for next read.
  systime_t wakeTime = chVTGetSystemTimeX();

  while (TRUE) {
    wakeTime += 10;
    chThdSleepUntil(wakeTime);
    seconds_counter++;
    chtime1 = chVTGetSystemTimeX();
  }
}

Even I set

Code: Select all

 #define CH_CFG_ST_RESOLUTION 32

after reaching chtime1 ~65000 the seconds_counter and chtime1 show 6534 and 4..
I suspect something weird with chVTGetSystemTimeX() or with systime_t size. The variant with chTimeNow() worked fine..
PS: seconds_counter counts 100/second, but that is not important here..

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: CB3.0 F100 - I2C issues

Postby Giovanni » Tue Oct 08, 2013 7:44 pm

chVTGetSystemTimeX() is exactly chTimeNow(). The counter cannot be 32bits because the tickless mode uses TIM2 and TIM2 is 16 bits on the STM32F1 (it should give you a compile error however).

If you need a 32 bits counter then disable the tickless mode or use another STM32.

Giovanni

pito
Posts: 199
Joined: Sun Nov 06, 2011 3:54 pm

Re: CB3.0 F100 - I2C issues

Postby pito » Tue Oct 08, 2013 7:55 pm

Ah, yea, tickless mode requires a hw counter.. thanks.
The next step is the I2c..

pito
Posts: 199
Joined: Sun Nov 06, 2011 3:54 pm

Re: CB3.0 F100 - I2C issues

Postby pito » Tue Oct 08, 2013 8:52 pm

Chibi30\os\hal\ports\STM32\I2Cv1\i2c_lld.c

l.146

Code: Select all

 osalDbgCheck((i2cp != NULL) &&
               (clock_speed > 0) &&
               (clock_speed <= 4000000));  <<<< Typo

pito
Posts: 199
Joined: Sun Nov 06, 2011 3:54 pm

Re: CB3.0 F100 - I2C issues

Postby pito » Wed Oct 09, 2013 12:16 pm

Including the following code into my source causes the system halts around i2cstart (it works in trunk).. If somebody may see an issue below, give me a hint , plz :x

Code: Select all

..
#include "chTinyRTC8563.h"
..
static const I2CConfig i2cfg1 = {OPMODE_I2C, 400000, FAST_DUTY_CYCLE_16_9};   //40Mhz clock
..
main:
..
  /* Starts I2C1  PB6=SCL PB7=SDA */
  palSetPadMode(GPIOB, 6, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
  palSetPadMode(GPIOB, 7, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);

  i2cStart(&I2CD1, &i2cfg1);     <<<<<<<<<<

  if (RTC_PCF8563_isrunning()) {
..


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 43 guests