12f675 code size - puzzled ?

Beta Testing discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
srnet
Posts: 163
Joined: 28 Mar 2009 17:14

12f675 code size - puzzled ?

#1 Post by srnet » 05 Apr 2009 15:05

I have been working on a Radio Remote Control interface for the CHDK software for Canon cameras.

Basically it reads the length of the RC input pules (1-2ms) and outputs a pulse (100-600ms) to the USB interface.

The pulse is times with a simple loop, there is a check to see if the pin is stuck. It would be nice if the pulse could be measured exactly in units of uS (as in PIC Basic PRO - pulsein) but its not important, its easy enough to calibrate.

For a 1ms pulse std Mickrobasic counts 60 loops in 1ms, the PRO version manages 100, a significant improvement.

But ........... to check code size I set up a test program, it sets OSCAL, times the pulse and sends the result out to the Soft_Uart.

Code size with std Mikrobasic is 225 bytes and with the Pro version its 911 bytes, more than 4 times as much.

Also the pro version seems to think a 12f675 has 2048 bytes of ROM and 96 bytes of RAM ?

Kalain
Posts: 1093
Joined: 11 Mar 2005 18:26
Location: Aubenas, France

Re: 12f675 code size - puzzled ?

#2 Post by Kalain » 05 Apr 2009 17:12

srnet wrote: Code size with std Mikrobasic is 225 bytes and with the Pro version its 911 bytes, more than 4 times as much.
Can you post some code. This will give better idea than thought.
Also the pro version seems to think a 12f675 has 2048 bytes of ROM and 96 bytes of RAM ?
Yes there is a definition problem with 12F629/675, 12F635 and MB Pro.
(This definition problem was already there in MB7.x)

12F629/675 has (from datasheet) :
- 1024 Flash memory.
- 64 SRAM
- 128 EEPROM.
Alain

srnet
Posts: 163
Joined: 28 Mar 2009 17:14

#3 Post by srnet » 05 Apr 2009 17:27

The code may look odd, its part of a larger program and I stripped out a lot of stuff just to test the pulse timing loop.

program testloop
'* Notice : Copyright (c) 2009
'* : All Rights Reserved
'* Date : 02/04/2009
'* Version : 1.0

const timeout3 as byte = 255

dim pulsewidth as word 'measured width of Channel 1 RC input pulse

sub Procedure CAL 'called from main
OSCCAL = OSCCAL 'This line has to be added for linker to recognise OSCCAL
ASM
bsf STATUS,RP0
call 0x3FF
movwf OSCCAL 'calibrate oscillator
bcf STATUS,RP0
END ASM
end sub

main:

INTCON = $0 ' disable all ints
TRISIO = %00001111 'gpio.4, gpio.5 output, rest to input
WPU = %00000000 'weak pull ups

CMCON = %00000111 'Comparator off on all IPs and Ops
ADCON0 = %00000100
ANSEL = %00000000 'analogue off
OPTION_REG = %00000000 'ensure Weak pull ups are enabled
cal

'set up the sofware USART
soft_uart_init(gpio, 1, 4, 9600, 1)

loop1:

pulsewidth = 0
'pulse is low, wait for it to go high
while gpio.0 = 0
inc(pulsewidth) 'pulsewidth = pulsewidth + 1
wend


'make sure pulsewidth starts at 0
pulsewidth=0

'pulse has been low now gone high so measure it.
while gpio.0 = 1
inc(pulsewidth)
pulsewidth = pulsewidth + 1
if pulsewidth = timeout3 then
Soft_UART_Write($55) 'char acts as a flag
break 'exits the while loop
end if
wend

'write out the measued pulsewidth
Soft_UART_Write(pulsewidth)
soft_UART_Write($0d)
soft_UART_Write($0a)
goto loop1

end.

Kalain
Posts: 1093
Joined: 11 Mar 2005 18:26
Location: Aubenas, France

#4 Post by Kalain » 05 Apr 2009 18:23

Hi,

Code: Select all

soft_uart_init(gpio, 1, 4, 9600, 1)
Instruction above (12F675) takes nearly 770 Rom with MB Pro and only around 25 with MB7.0.0.2 !!!

Sure, there is something wrong around this instruction.......

I have to import/convert 1450 lines from MB7.2 into MB Pro.
I'm looking forward what will be the difference!
Alain

srnet
Posts: 163
Joined: 28 Mar 2009 17:14

#5 Post by srnet » 05 Apr 2009 18:38

I never thought to check the histogram, I get for pro;

soft_uart_init 224 bytes
div_32x32_s 154 bytes
sdiv3232l 300 bytes.

The last two suggest 32 bit division ?

srnet
Posts: 163
Joined: 28 Mar 2009 17:14

#6 Post by srnet » 05 Apr 2009 18:50

Oh, and mul_32x32_u is in the pro version too.

32 bit unsigned multiply ?

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#7 Post by janni » 06 Apr 2009 14:08

Milan explained the code size difference for soft uart here http://www.mikroe.com/forum/viewtopic.p ... 06&start=8

sjm
Posts: 1
Joined: 02 Jun 2009 22:48

12f675 soft_uart code size

#8 Post by sjm » 02 Jun 2009 23:43

Hello to all!

I have been "playing" with the demo version of PB 7.0.0.2 to make RS232 controlled relay switches and a 4ch A/D-converter with serial output, all using 12F675 (1k code memory).

Trying to use PB PRO for the same projects, I am left with almost no program memory besides the soft_uart routines... Simultaneously using soft_i2c would be impossible I think, as it seems from other posts that these routines are also "memory hungry".

For me then, these facts will render PB PRO useless for my projects using the smaller PICs without hardware USARTs.

I fully appreciate MEs wish to make "better" code, but sadly it leads to bigger code for the soft_uart and (afaik) soft_i2c.

So my ultimate wish would be for ME to make not only "better", but "smarter" and more compact code :-)

At the moment, this "problem" is keeping me from buying PB PRO, which I would oherwise not hesitate to do, as I consider it very good value for money. (I realize I can stick with the limited "demo" 7.0.0.2 version for the smaller PICs, but I would rather pay the price to get the full product with continued development and support from ME).

So, ME team; can you please (re)consider...? :-)
(Your reward would be at least one more happy customer...!)


Best regards
sjm

Jack Flanders
Posts: 337
Joined: 17 Apr 2008 02:53
Location: Fantasy Land

#9 Post by Jack Flanders » 03 Jun 2009 02:37

srnet wrote:
I have been working on a Radio Remote Control interface for the CHDK software for Canon cameras.
Hi srnet,

I would like to ask you a few questions:
What camera are you using?
How is your project coming along?
Do you have photos to see yet?
What is the RC part of your project?

Why am I so curious? I made one also, with a '675 but all it does is detect long or short on a spare channel.

srnet
Posts: 163
Joined: 28 Mar 2009 17:14

Re: 12f675 code size - puzzled ?

#10 Post by srnet » 25 Jan 2011 14:48

I realise this is an old post, but I have come back to the original problem.

The code for my Canon CHDK controller is for a 12f675, it uses the SOFT_UART to print out diagnostics on measured pulses, this simple program;

program UARTTEST

'* Notice : Copyright (c) 2010
'* : All Rights Reserved
'* Date : 21/01/2011
'* Version : 1.0

sub procedure CRLF
Soft_Uart_Write($0a) 'send cr lf to uart
Soft_Uart_Write($0d)
end sub

main:
soft_uart_init(gpio, 3, 1, 2400, 1)
crlf()
loop1:
goto loop1
end.


Takes 162 Words in Mikrobasic V7 and 892 in the latest Mikrobasic PRO. The entire program needs about and extra 700 words in V7 and gets nowhere near compling in PRO.

Is the old SOFT_UART or a version of it ever going to be included in the libraries again ?

Failing that, is the old V7 compiler still freely avaialble for download so that it can be used in demo mode ?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: 12f675 code size - puzzled ?

#11 Post by filip » 26 Jan 2011 16:15

Hi,

The difference between these two versions in a way that the baud rate is calculated.
In the earlier versions, in was the built-in routine and once the baud rate was calculated, it couldn't be changed anymore.

Now, the baud rate calculation is performed in the library and you can set the change the baud rated (re-initialize the module with different baud rate) as much as you wish.

Nevertheless, i will give you the address of the old mikroBasic :
http://www.mikroe.com/eng/downloads/get ... _setup.zip

Regards,
Filip.

Post Reply

Return to “mikroBasic PRO for PIC Beta Testing”