UDB Counter values update

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jepaz
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

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
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked
        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
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

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
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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