cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

jepaz
New Contributor II

Hi Everyone,

   

I am having trouble with a Counter, my program has an EEPROM memory from which it reads the values and updates the counter,

   

I cant get the values to update.

   

the counter triggers an interrupt with a compare value

   

void update(){ 
    Counter_Stop();
     Counter_WritePeriod(revcount);
    Counter_WriteCompare(revcount);     
    Counter_WriteCounter(0); 

   

   Counter_SaveConfig();  
    Timer_WritePeriod(Period);  
    Timer_WriteCounter(Period); 
    Counter_Start();
    clr();screen();
}

0 Likes
7 Replies
JoMe_264151
Expert II

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
JoMe_264151
Expert II

Are you aware that revcount and period are 16 bit ints while your counter is only 8 bits wide.

   

in function update() is no reasonable code, commented due to despair ?  😉

   

I cannot find a place where you read data from eepromArray

   

 

   

Bob

0 Likes
jepaz
New Contributor II
        Yo Bob don't worry about the eeprom, yes I just noticed the udb was 8 bit, I need to make the update function work it was all commented because i was trying and checking when the update routine is ran it should change the period and compare values, it seems to require a reload don't know what to do Thank you   
0 Likes
JoMe_264151
Expert II

When still in trouble, do not hesitate to upload your latest project archive. Someone will have a look into it.

   

 

   

Bob

0 Likes
JoMe_264151
Expert II

You are still writing the number 300 +50 into an 8-bit wide component. Max is 255.

   

Do not wait  with CyDelay() within an interrupt handler, the system might stall.

   

I cannot see what is not running, all values are as I expect them.

   

 

   

Bob

0 Likes
jepaz
New Contributor II

please change the udb to 16bit, I am trying to update the counter period and compare values through firmware, when i run it the values are the ones set up in the hardware block

   

 

   

thanks

0 Likes
JoMe_264151
Expert II

At least put into your Init() function a Counter_Init(), so that the first Counter_Start() does not overwrite your settings.

   

I do not make changes in your program, there will be differences between our code too quickly.

   

 

   

Bob

0 Likes