I2C - stops at one point of program

A catchall for PSoC Mixed-Signal Array (microcontroller) discussions not captured by the other forums.

Moderator: ericb

I2C - stops at one point of program

Postby Piotrbov » Sat Apr 26, 2014 10:15 am

Hello and welcome again ;)

I've got some strange problem, and can't find any solution.

I want to implement one element using I2C in my project. I've made functions (named: readPressHW(); and PressureCalc(); ) etc. and... when I put this functions to work in main.c in the while(1){[...]} this is working normally. The results are appering on the LCD, but...

When I want to use this functions in the Interrupt function (Sleep_ISR), in function readPressHW(); the program is stopping on the line

Code: Select all
I2CHW_bWriteBytes(MPLAddress, txBuffer,1,I2CHW_CompleteXfer);

and I don't know why...

I upload my project.
Attachments
Baza_Meteo.Archive1.zip
(1.06 MiB) Downloaded 137 times
Piotrbov
Newbie
Newbie
 
Posts: 8
Joined: Fri Apr 12, 2013 2:24 am

Re: I2C - stops at one point of program

Postby bobmarlowe » Sat Apr 26, 2014 12:08 pm

Your interrupt handlers are a bit lengthy, do not forget that writing to LCD is using some delays which is a strict no-go for interrupt handlers. better off you are when in handler just set a flag and exit and checking for the flag in main-loop.

I2C does not work in an interrupt handler. When the handler is entered all interrupts are disabled, but I2C works interrupt-driven only. When quite sure that you do not mess up anything you may re-enable the interrupts in your handler back again.


Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: I2C - stops at one point of program

Postby Piotrbov » Sat Apr 26, 2014 12:57 pm

Thank you very much for advice ;)

I will try it.
Piotrbov
Newbie
Newbie
 
Posts: 8
Joined: Fri Apr 12, 2013 2:24 am


Return to “%s” PSoC1 General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests