Author |
Message |
Topic: Timer0 interrupt and printf |
foxOnTheRun
Replies: 5
Views: 8117
|
Forum: General CCS C Discussion Posted: Mon Oct 21, 2013 1:25 pm Subject: Timer0 interrupt and printf |
Straight to the point:
PIC16F690@8MHz (internal osc).
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_bit);
I'm using this to generate 1khz pwm:
#int_TIMER0
void TIMER0_isr(void) // 2 ... |
Topic: Code optimization: cascade of IFs statement vs switch..case |
foxOnTheRun
Replies: 4
Views: 9275
|
Forum: General CCS C Discussion Posted: Sun Jan 29, 2012 4:55 am Subject: Code optimization: cascade of IFs statement vs switch..case |
All right, I understood your explanation, thanks.
This explains also why somewhere in the code a:
printf("%4Lu",x);
would give less compiled filesize than:
printf(&qu ... |
Topic: Code optimization: cascade of IFs statement vs switch..case |
foxOnTheRun
Replies: 4
Views: 9275
|
Forum: General CCS C Discussion Posted: Sun Jan 29, 2012 4:06 am Subject: Code optimization: cascade of IFs statement vs switch..case |
Hi, using compiler 4.124 and in the code I have:
if (stage == 0) t1++; // stage fast 160ma
if (stage == 1) t2++; // stage slow 80ma
if (stage == 2) t3++; // 40ma
if ( ... |
Topic: Need help on Flex 20x4 lcd driver |
foxOnTheRun
Replies: 6
Views: 10831
|
Forum: General CCS C Discussion Posted: Thu Jul 07, 2011 6:02 am Subject: Need help on Flex 20x4 lcd driver |
Have you tried to power up the display without the PIC attached to data lines? It should display an entire row of black squares.
Just a quick checklist:
_ make triple sure every pin of your PIC ... |
Topic: Execution time: how to check length of code block |
foxOnTheRun
Replies: 11
Views: 21644
|
Forum: General CCS C Discussion Posted: Thu Jul 07, 2011 3:50 am Subject: Execution time: how to check length of code block |
Updates (I'm updating with the intent that this topic could be usefull for other reader in the future):
I have found what was slowing down everything:
printf(lcd_putc,"%3.2wV", val ... |
Topic: Execution time: how to check length of code block |
foxOnTheRun
Replies: 11
Views: 21644
|
Forum: General CCS C Discussion Posted: Wed Jul 06, 2011 6:59 am Subject: Execution time: how to check length of code block |
Yes, you are perfectly right, instructions have to be executed by something/somewhere, they do not come up from thin air.
I was thinking at some solutions, lowering the software pwm, demux the nati ... |
Topic: Execution time: how to check length of code block |
foxOnTheRun
Replies: 11
Views: 21644
|
Forum: General CCS C Discussion Posted: Tue Jul 05, 2011 6:36 am Subject: Execution time: how to check length of code block |
Updates.
I'm "somewhat" mapping the execution time of the PIC, result pretty much match the timings given in the guide section.
I was quite satisfied by just 445 int32 += int32*int32, ... |
Topic: Execution time: how to check length of code block |
foxOnTheRun
Replies: 11
Views: 21644
|
Forum: General CCS C Discussion Posted: Sat Jul 02, 2011 3:47 pm Subject: Execution time: how to check length of code block |
Update:
To get the execution time of some instruction, I've resorted to this way:
enable_interrupts(int_TIMER1);
leap=0;
set_timer1(0);
... |
Topic: To Float or not to float? |
foxOnTheRun
Replies: 12
Views: 15378
|
Forum: General CCS C Discussion Posted: Sat Jul 02, 2011 3:46 pm Subject: To Float or not to float? |
Glad you have worked out a solution that suits.
It might be quite 'informative', to just run this part of the code in MPLAB simulator, and time it. The division by 64, should only take perhaps a do ... |
Topic: generating PWM from timers --> debugging generated freque |
foxOnTheRun
Replies: 2
Views: 5301
|
Forum: General CCS C Discussion Posted: Sat Jul 02, 2011 2:44 am Subject: generating PWM from timers --> debugging generated freque |
Oh my!
You were.. ARE right!
To tell the truth, before posting I tried a slower PWM, like having an int after a full count of timer0, and it was interrupting/overflowing correctly every 32ms.. b ... |
Topic: generating PWM from timers --> debugging generated freque |
foxOnTheRun
Replies: 2
Views: 5301
|
Forum: General CCS C Discussion Posted: Fri Jul 01, 2011 5:13 pm Subject: generating PWM from timers --> debugging generated freque |
Ok, I was reclutant to post this, but untill now I haven't found an explanation.
I'm using timer0 (or timer1), every overflow I just toggle the value of a pin, so I can generate a pwm signal, nothi ... |
Topic: To Float or not to float? |
foxOnTheRun
Replies: 12
Views: 15378
|
Forum: General CCS C Discussion Posted: Fri Jul 01, 2011 3:40 pm Subject: To Float or not to float? |
Consider the difference between floats and fixed point numbers. You can calculate integer millidegrees much faster than you can true floats, and use %w to put the decimal where it belongs for display ... |
Topic: To Float or not to float? |
foxOnTheRun
Replies: 12
Views: 15378
|
Forum: General CCS C Discussion Posted: Fri Jul 01, 2011 10:07 am Subject: To Float or not to float? |
If val_temp is coming from an A/D reading your LM35 you probably aren't getting more than 12 bits, and in most applications 8 bits will do fine. Properly scaled 8 bits gives better than 0.5% resoluti ... |
Topic: To Float or not to float? |
foxOnTheRun
Replies: 12
Views: 15378
|
Forum: General CCS C Discussion Posted: Fri Jul 01, 2011 10:01 am Subject: To Float or not to float? |
and some more comments:
*0.609327, would immediately be several times faster.
Now remembering the comment about binary divisions, multiply by 256
So:
printf(lcd_putc,"Batt:%3.1LwC ... |
Topic: To Float or not to float? |
foxOnTheRun
Replies: 12
Views: 15378
|
Forum: General CCS C Discussion Posted: Fri Jul 01, 2011 9:36 am Subject: To Float or not to float? |
and some more comments:
Float's are _not_ the 'format of values from sensors'. Numbers arriving from sensors will always be integers
Best Wishes
Right, but I was viewing a sensor from end use ... |
|