Re: [jallib] adc average

2021-11-13 Thread vsurducan
Yes indeed it was a simulation. Still very valuable as long as it replaces
nasty debugging...

I've solved the issue. The problem was the length of the ADC procedure.
It's good to know/remember that if use only four ADC channels from 23
available (PIC18F25k50):
- all registers which can be set prior to run the procedure should be done
only once (ADCON2_ADCS, ADCON2_ACQT, ADCON1_PVCFG, ADCON1_NVCFG,
ADCON2_ADFM, ANSELB, ANSELC)
-even the ADC has 23 channels, only the four used should be kept in the
if-elsif-end structure, else the compile will waste time with if procedure
instead of doing other useful things
As a conclusion (I already known): there isn't a universal ADC library
which can be used properly  in any situation.
thx all,



On Sat, Nov 13, 2021 at 2:28 PM 'Oliver Seitz' via jallib <
jallib@googlegroups.com> wrote:

>
>
> Am Samstag, 13. November 2021, 12:27:04 MEZ hat vsurducan <
> vsurdu...@gmail.com> Folgendes geschrieben:
>
>
> "Old jal (Wouter's) had a feature for testing computation at the compile
> time. I realized it was very useful even if using constants for testing
> math routines."
>
>
> If that is the case, it's still no part of compilation but some sort of
> simulation. Can be that it was included in that compiler, but it's nothing
> a compiler needs to do in general.
>
> Greets,
> Kiste
>
> --
> You received this message because you are subscribed to the Google Groups
> "jallib" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jallib+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jallib/408706160.298701.1636806482097%40mail.yahoo.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jallib+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/CAM%2Bj4qt1O%3DipTHvZt3-qHO1fPixSJ%2B5hHXhAp9thLGCvKefThg%40mail.gmail.com.


[jallib] [jallib build] buildbot success in jallib on jallib-standard

2021-11-13 Thread build
Hi guys,

This is buildbot speaking. I have finished a build of jallib-standard on jallib.
Buildslave for this Build: sebbot

Build Reason: 
Build Source Stamp: HEAD
Blamelist: rob.jansen

Build succeeded!
Logs are attached.

sincerely,
 -The Buildbot

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jallib+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/E1mm5CM-0004np-8L%40casadeyork.com.
Updating '.':

UU   include/external/lcd/glcd_ssd1306.jal

Updated to revision 3778.

2724 samples to validate...

1117 libraries to validate...

All files validated :)

Environment config

JALLIB_ROOT=/home/mattschinkel/jallib/slave/standard/build

JALLIB_REPOS=/home/mattschinkel/jallib/slave/standard/build/include

JALLIB_SAMPLEDIR=/home/mattschinkel/jallib/slave/standard/build/sample

JALLIB_JALV2=/home/mattschinkel/bin/jalv2

JALLIB_PYTHON=python2.7



Time duration: 429 secs

jal jalv25r6 (compiled Oct 29 2021)

Required parameter to hex is missing!

no source file, use /home/mattschinkel/bin/jalv2 --help for help

Error while compiling file (status=1).

See previous message.

2724 samples to compile...

All samples compile :)

Environment config

JALLIB_ROOT=/home/mattschinkel/jallib/slave/standard/build

JALLIB_REPOS=/home/mattschinkel/jallib/slave/standard/build/include

JALLIB_SAMPLEDIR=/home/mattschinkel/jallib/slave/standard/build/sample

JALLIB_JALV2=/home/mattschinkel/bin/jalv2

JALLIB_PYTHON=python2.7



Time duration: 2502 secs



[jallib] [jallib/jallib] cf2e14: Update glcd_ssd1306.jal

2021-11-13 Thread 'Rob Jansen' via jallib
  Branch: refs/heads/master
  Home:   https://github.com/jallib/jallib
  Commit: cf2e146811bbba34bbd2c42bfb65328a00ec548d
  
https://github.com/jallib/jallib/commit/cf2e146811bbba34bbd2c42bfb65328a00ec548d
  Author: Rob Jansen <12682653+robjanse...@users.noreply.github.com>
  Date:   2021-11-13 (Sat, 13 Nov 2021)

  Changed paths:
M include/external/lcd/glcd_ssd1306.jal

  Log Message:
  ---
  Update glcd_ssd1306.jal

Small fix as to be able to select another IIC bus speed.


-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jallib+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/jallib/jallib/push/refs/heads/master/58bc87-cf2e14%40github.com.


Re: [jallib] adc average

2021-11-13 Thread 'Oliver Seitz' via jallib
 

Am Samstag, 13. November 2021, 12:27:04 MEZ hat vsurducan 
 Folgendes geschrieben:  
 
 "Old jal (Wouter's) had a feature for testing computation at the compile time. 
I realized it was very useful even if using constants for testing math 
routines."


If that is the case, it's still no part of compilation but some sort of 
simulation. Can be that it was included in that compiler, but it's nothing a 
compiler needs to do in general.
Greets,Kiste
  

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jallib+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/408706160.298701.1636806482097%40mail.yahoo.com.


Re: [jallib] adc average

2021-11-13 Thread vsurducan
Thanks Rob, I've done this but perhaps I've missed something.
I'm thinking of moving the ADC reading completely in the ISR.
thank you!


On Sat, Nov 13, 2021 at 1:40 PM Rob CJ  wrote:

> Hi Vasile,
>
> I am not sure what you are doing but if you read words in a main loop that
> are changed (written) in an interrupt routine you can get data corruption
> since more cycles are need to write a word (or read it).
>
> The easiest way to fix this is to disable all interrupts (or at least the
> interrupt routine that writes the word) in the main loop just before
> reading it and enable it again as soon as you have read the word.
>
> Kind regards,
>
> Rob
>
> --
> *Van:* jallib@googlegroups.com  namens vsurducan
> 
> *Verzonden:* zaterdag 13 november 2021 12:26
> *Aan:* jallib@googlegroups.com 
> *Onderwerp:* Re: [jallib] adc average
>
> Hi Kiste, this is the way I'm debugging right now, not on LCD but on PC
> via USB (that's because I'm using the USB ).
> Old jal (Wouter's) had a feature for testing computation at the compile
> time. I realized it was very useful even if using constants for testing
> math routines.
>
> My problem is related to the folloswing issue:
> I have a flag in the isr which is changing (flag = !flag)  each 400uS.
> In the main program I test the flag and during one state I'm switching
> some fast mosfets and reading a pair of voltage/current, during the other
> state I'm switching again the mosfets in a different way and reading again
> the voltage/current pair. Everything looks ok on the digital analyzer and
> scope.
>
> As long the length of the code involved with ADC read is running below
> 400us, I should read correct values for voltage/current.
> However, if the length of the main code is too short or too long ( and
> this happens around 3800h) I get corrupted adc data reads in a way I do not
> understand it.
> In a situation a longer program data creates good readings... :)
>
> So I can only suppose it is a compiler bug related to words manipulations
> or page/bank issues.
> thx
>
>
>
> On Sat, Nov 13, 2021 at 12:45 PM 'Oliver Seitz' via jallib <
> jallib@googlegroups.com> wrote:
>
> Hi!
>
> _error is meant to produce an error whenever it is compiled. You can only
> use it with constants:
>
> if target_clock<1200 then
>   _error "Need at least 12MHz for this program"
> end if
>
> If there's a variable in the if statement, the content will have to be
> compiled, and so the error is raised.
>
> If you want to see characters depending on a value of a variable, you can
> only check at runtime. So, connect some kind of a display and use
> print_string()
>
>
> Greets,
> Kiste
>
> Am Samstag, 13. November 2021, 09:56:29 MEZ hat Rob CJ 
> Folgendes geschrieben:
>
>
> Hi Vasile,
>
> Thanks for the update. I found something strange. Given the code below.
>
> include 18f4550
>
> var byte i = 0
>
> if (i == 100) then
>   _error "Is 100"
> end if
>
> When I compile this I get:
>
> jal jalv25r6 (compiled Oct 29 2021)
> generating p-code
> 16858 tokens, 151522 chars; 3221 lines; 3 files
> generating PIC code pass 1
> generating PIC code pass 2
> 0 data accesses checked, 0 errors
> 1 skips checked, 0 errors
> writing result
> d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "Is 100"
> 1 errors, 0 warnings
> The terminal process "c:\jallib\compiler\jalv2_64.exe
> 'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'"
> terminated with exit code: 1.
>
> Which is not correct. Same happens when you replace it with _warn but then
> it is generated as warning.
>
> But when I have this program:
>
> include 18f4550
>
> var byte i = 0
>
> if !defined(i) then
>   _error "i is not defined"
> end if
>
> I get:
>
> jal jalv25r6 (compiled Oct 29 2021)
> generating p-code
> 16858 tokens, 151533 chars; 3221 lines; 3 files
> generating PIC code pass 1
> generating PIC code pass 2
> 0 data accesses checked, 0 errors
> 0 skips checked, 0 errors
> writing result
> Code area: 6 of 32768 used (bytes)
> Data area: 1 of 2048 used
> Software stack available: 2046 bytes
> Hardware stack depth 0 of 31
> 0 errors, 0 warnings
>
> Which is correct because when I change i to j the output is:
>
> jal jalv25r6 (compiled Oct 29 2021)
> generating p-code
> 16858 tokens, 151533 chars; 3221 lines; 3 files
> generating PIC code pass 1
> generating PIC code pass 2
> 0 data accesses checked, 0 errors
> 0 skips checked, 0 errors
> writing result
> d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "i is not defined"
> 1 errors, 0 warnings
> The terminal process "c:\jallib\compiler\jalv2_64.exe
> 'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'"
> terminated with exit code: 1.
>
> So not sure why this happens but is seems to be not OK.
>
> Kind regards,
>
> Rob
>
> --
> *Van:* jallib@googlegroups.com  namens vsurducan
> 
> *Verzonden:* zaterdag 13 november 2021 08:08
> *Aan:* jallib@googlegroups.com 
> *Onderwerp:* Re: [jallib] adc 

Re: [jallib] adc average

2021-11-13 Thread Rob CJ
Hi Vasile,

I am not sure what you are doing but if you read words in a main loop that are 
changed (written) in an interrupt routine you can get data corruption since 
more cycles are need to write a word (or read it).

The easiest way to fix this is to disable all interrupts (or at least the 
interrupt routine that writes the word) in the main loop just before reading it 
and enable it again as soon as you have read the word.

Kind regards,

Rob


Van: jallib@googlegroups.com  namens vsurducan 

Verzonden: zaterdag 13 november 2021 12:26
Aan: jallib@googlegroups.com 
Onderwerp: Re: [jallib] adc average

Hi Kiste, this is the way I'm debugging right now, not on LCD but on PC via USB 
(that's because I'm using the USB ).
Old jal (Wouter's) had a feature for testing computation at the compile time. I 
realized it was very useful even if using constants for testing math routines.

My problem is related to the folloswing issue:
I have a flag in the isr which is changing (flag = !flag)  each 400uS.
In the main program I test the flag and during one state I'm switching some 
fast mosfets and reading a pair of voltage/current, during the other state I'm 
switching again the mosfets in a different way and reading again the 
voltage/current pair. Everything looks ok on the digital analyzer and scope.

As long the length of the code involved with ADC read is running below 400us, I 
should read correct values for voltage/current.
However, if the length of the main code is too short or too long ( and this 
happens around 3800h) I get corrupted adc data reads in a way I do not 
understand it.
In a situation a longer program data creates good readings... :)

So I can only suppose it is a compiler bug related to words manipulations or 
page/bank issues.
thx



On Sat, Nov 13, 2021 at 12:45 PM 'Oliver Seitz' via jallib 
mailto:jallib@googlegroups.com>> wrote:
Hi!

_error is meant to produce an error whenever it is compiled. You can only use 
it with constants:

if target_clock<1200 then
  _error "Need at least 12MHz for this program"
end if

If there's a variable in the if statement, the content will have to be 
compiled, and so the error is raised.

If you want to see characters depending on a value of a variable, you can only 
check at runtime. So, connect some kind of a display and use print_string()


Greets,
Kiste

Am Samstag, 13. November 2021, 09:56:29 MEZ hat Rob CJ 
mailto:rob...@hotmail.com>> Folgendes geschrieben:


Hi Vasile,

Thanks for the update. I found something strange. Given the code below.

include 18f4550

var byte i = 0

if (i == 100) then
  _error "Is 100"
end if

When I compile this I get:

jal jalv25r6 (compiled Oct 29 2021)
generating p-code
16858 tokens, 151522 chars; 3221 lines; 3 files
generating PIC code pass 1
generating PIC code pass 2
0 data accesses checked, 0 errors
1 skips checked, 0 errors
writing result
d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "Is 100"
1 errors, 0 warnings
The terminal process "c:\jallib\compiler\jalv2_64.exe 
'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'" 
terminated with exit code: 1.

Which is not correct. Same happens when you replace it with _warn but then it 
is generated as warning.

But when I have this program:

include 18f4550

var byte i = 0

if !defined(i) then
  _error "i is not defined"
end if

I get:

jal jalv25r6 (compiled Oct 29 2021)
generating p-code
16858 tokens, 151533 chars; 3221 lines; 3 files
generating PIC code pass 1
generating PIC code pass 2
0 data accesses checked, 0 errors
0 skips checked, 0 errors
writing result
Code area: 6 of 32768 used (bytes)
Data area: 1 of 2048 used
Software stack available: 2046 bytes
Hardware stack depth 0 of 31
0 errors, 0 warnings

Which is correct because when I change i to j the output is:

jal jalv25r6 (compiled Oct 29 2021)
generating p-code
16858 tokens, 151533 chars; 3221 lines; 3 files
generating PIC code pass 1
generating PIC code pass 2
0 data accesses checked, 0 errors
0 skips checked, 0 errors
writing result
d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "i is not defined"
1 errors, 0 warnings
The terminal process "c:\jallib\compiler\jalv2_64.exe 
'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'" 
terminated with exit code: 1.

So not sure why this happens but is seems to be not OK.

Kind regards,

Rob


Van: jallib@googlegroups.com 
mailto:jallib@googlegroups.com>> namens vsurducan 
mailto:vsurdu...@gmail.com>>
Verzonden: zaterdag 13 november 2021 08:08
Aan: jallib@googlegroups.com 
mailto:jallib@googlegroups.com>>
Onderwerp: Re: [jallib] adc average

Hi Rob,
I think you will not find any issue, please don't bother. The code works now 
(without interrupts), I had a multiplication error which is not part of the 
code.
My original test used  tmr0 interrupt and USB_serial, the average measurements 
should 

Re: [jallib] adc average

2021-11-13 Thread vsurducan
Hi Kiste, this is the way I'm debugging right now, not on LCD but on PC via
USB (that's because I'm using the USB ).
Old jal (Wouter's) had a feature for testing computation at the compile
time. I realized it was very useful even if using constants for testing
math routines.

My problem is related to the folloswing issue:
I have a flag in the isr which is changing (flag = !flag)  each 400uS.
In the main program I test the flag and during one state I'm switching some
fast mosfets and reading a pair of voltage/current, during the other state
I'm switching again the mosfets in a different way and reading again the
voltage/current pair. Everything looks ok on the digital analyzer and scope.

As long the length of the code involved with ADC read is running below
400us, I should read correct values for voltage/current.
However, if the length of the main code is too short or too long ( and this
happens around 3800h) I get corrupted adc data reads in a way I do not
understand it.
In a situation a longer program data creates good readings... :)

So I can only suppose it is a compiler bug related to words manipulations
or page/bank issues.
thx



On Sat, Nov 13, 2021 at 12:45 PM 'Oliver Seitz' via jallib <
jallib@googlegroups.com> wrote:

> Hi!
>
> _error is meant to produce an error whenever it is compiled. You can only
> use it with constants:
>
> if target_clock<1200 then
>   _error "Need at least 12MHz for this program"
> end if
>
> If there's a variable in the if statement, the content will have to be
> compiled, and so the error is raised.
>
> If you want to see characters depending on a value of a variable, you can
> only check at runtime. So, connect some kind of a display and use
> print_string()
>
>
> Greets,
> Kiste
>
> Am Samstag, 13. November 2021, 09:56:29 MEZ hat Rob CJ 
> Folgendes geschrieben:
>
>
> Hi Vasile,
>
> Thanks for the update. I found something strange. Given the code below.
>
> include 18f4550
>
> var byte i = 0
>
> if (i == 100) then
>   _error "Is 100"
> end if
>
> When I compile this I get:
>
> jal jalv25r6 (compiled Oct 29 2021)
> generating p-code
> 16858 tokens, 151522 chars; 3221 lines; 3 files
> generating PIC code pass 1
> generating PIC code pass 2
> 0 data accesses checked, 0 errors
> 1 skips checked, 0 errors
> writing result
> d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "Is 100"
> 1 errors, 0 warnings
> The terminal process "c:\jallib\compiler\jalv2_64.exe
> 'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'"
> terminated with exit code: 1.
>
> Which is not correct. Same happens when you replace it with _warn but then
> it is generated as warning.
>
> But when I have this program:
>
> include 18f4550
>
> var byte i = 0
>
> if !defined(i) then
>   _error "i is not defined"
> end if
>
> I get:
>
> jal jalv25r6 (compiled Oct 29 2021)
> generating p-code
> 16858 tokens, 151533 chars; 3221 lines; 3 files
> generating PIC code pass 1
> generating PIC code pass 2
> 0 data accesses checked, 0 errors
> 0 skips checked, 0 errors
> writing result
> Code area: 6 of 32768 used (bytes)
> Data area: 1 of 2048 used
> Software stack available: 2046 bytes
> Hardware stack depth 0 of 31
> 0 errors, 0 warnings
>
> Which is correct because when I change i to j the output is:
>
> jal jalv25r6 (compiled Oct 29 2021)
> generating p-code
> 16858 tokens, 151533 chars; 3221 lines; 3 files
> generating PIC code pass 1
> generating PIC code pass 2
> 0 data accesses checked, 0 errors
> 0 skips checked, 0 errors
> writing result
> d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "i is not defined"
> 1 errors, 0 warnings
> The terminal process "c:\jallib\compiler\jalv2_64.exe
> 'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'"
> terminated with exit code: 1.
>
> So not sure why this happens but is seems to be not OK.
>
> Kind regards,
>
> Rob
>
> --
> *Van:* jallib@googlegroups.com  namens vsurducan
> 
> *Verzonden:* zaterdag 13 november 2021 08:08
> *Aan:* jallib@googlegroups.com 
> *Onderwerp:* Re: [jallib] adc average
>
> Hi Rob,
> I think you will not find any issue, please don't bother. The code works
> now (without interrupts), I had a multiplication error which is not part of
> the code.
> My original test used  tmr0 interrupt and USB_serial, the average
> measurements should happen in 400us intervals and it seems something went
> wrong because the values are not those expected.
>
> About the test procedure, I've loaded the ADRESH and ADRESL with constant
> values, without using any ADC_read procedure. Then tried to test the
> average procedure using _ERROR.  When the compiler finds the line
> containing _ERROR it reports an error no matter if the condition is true or
> false. Did I use it in the wrong way?
> A very old version of the JAL compiler used a pragma_test (or something
> like that) previously to start a testing procedure. The result was
> delivered at compile time.
> thank you,
>
>
> On Fri, Nov 12, 

Re: [jallib] adc average

2021-11-13 Thread 'Oliver Seitz' via jallib
 Hi!
_error is meant to produce an error whenever it is compiled. You can only use 
it with constants:
if target_clock<1200 then  _error "Need at least 12MHz for this program"end 
if
If there's a variable in the if statement, the content will have to be 
compiled, and so the error is raised. 
If you want to see characters depending on a value of a variable, you can only 
check at runtime. So, connect some kind of a display and use print_string()

Greets,Kiste
Am Samstag, 13. November 2021, 09:56:29 MEZ hat Rob CJ  
Folgendes geschrieben:  
 
 Hi Vasile,
Thanks for the update. I found something strange. Given the code below.
include 18f4550

var byte i =0
if (i == 100)then  _error "Is 100"end if
When I compile this I get:
jal jalv25r6 (compiled Oct 29 2021)generating p-code16858 tokens, 151522 chars; 
3221 lines; 3 filesgenerating PIC code pass 1generating PIC code pass 20 data 
accesses checked, 0 errors1 skips checked, 0 errors        writing 
resultd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "Is 100"1 errors, 0 
warningsThe terminal process "c:\jallib\compiler\jalv2_64.exe 
'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'" 
terminated with exit code: 1.

Which is not correct. Same happens when you replace it with _warn but then it 
is generated as warning.
But when I have this program:
include 18f4550

var byte i =0
if !defined(i)then  _error "i is not defined"end if
I get:
jal jalv25r6 (compiled Oct 29 2021)generating p-code16858 tokens, 151533 chars; 
3221 lines; 3 filesgenerating PIC code pass 1generating PIC code pass 20 data 
accesses checked, 0 errors0 skips checked, 0 errorswriting resultCode area: 6 
of 32768 used (bytes)Data area: 1 of 2048 usedSoftware stack available: 2046 
bytesHardware stack depth 0 of 310 errors, 0 warnings

Which is correct because when I change i to j the output is:
jal jalv25r6 (compiled Oct 29 2021)generating p-code16858 tokens, 151533 chars; 
3221 lines; 3 filesgenerating PIC code pass 1generating PIC code pass 20 data 
accesses checked, 0 errors0 skips checked, 0 errorswriting 
resultd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "i is not defined"1 
errors, 0 warningsThe terminal process "c:\jallib\compiler\jalv2_64.exe 
'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'" 
terminated with exit code: 1.

So not sure why this happens but is seems to be not OK.
Kind regards,
Rob
Van: jallib@googlegroups.com  namens vsurducan 

Verzonden: zaterdag 13 november 2021 08:08
Aan: jallib@googlegroups.com 
Onderwerp: Re: [jallib] adc average Hi Rob,I think you will not find any issue, 
please don't bother. The code works now (without interrupts), I had a 
multiplication error which is not part of the code.
My original test used  tmr0 interrupt and USB_serial, the average measurements 
should happen in 400us intervals and it seems something went wrong because the 
values are not those expected.

About the test procedure, I've loaded the ADRESH and ADRESL with constant 
values, without using any ADC_read procedure. Then tried to test the average 
procedure using _ERROR.  When the compiler finds the line containing _ERROR it 
reports an error no matter if the condition is true or false. Did I use it in 
the wrong way?A very old version of the JAL compiler used a pragma_test (or 
something like that) previously to start a testing procedure. The result was 
delivered at compile time.thank you,


On Fri, Nov 12, 2021 at 11:37 PM Rob CJ  wrote:

Hi Vasile,
If I want to test this I need to create a program that does not use your 
one_ch_ad_read routine. So if I use the standard adc library the program looks 
like this. Is this program giving the same problem for you (I do not know which 
PIC you are using but it seem to be an 18F)?
About the error and warning. They are only created at compile time and I am not 
sure what voltage is at the time you compile the the program. I am also not 
sure if this works for variables.

include 18f4550--pragma target clock 48_000_000-- magical statements: using a 
20MHz Xtal, you can run @48MHz !pragma target PLLDIV    P5pragma target CPUDIV  
  P1pragma target USBDIV    P2pragma target OSC      HS_PLL
pragma target WDT  control          -- watchdogpragma target LVP  enabled       
   -- allow Low Voltage Programmingpragma target MCLR external         -- reset 
externally
WDTCON_SWDTEN = off                -- no watchdog
-- We'll start to set all pins as digital-- then, using ADC lib, we'll 
configure needed-- ones as analog.enable_digital_io()
const sample_nr  = 8  ; buffer size dimensionvar word voltage1_a[sample_nr]; 
sample arrayvar word one_ch_ad_read, ch0_adc_valuevar word voltage1 =0 ; the 
average value we needconst word c256 =256

-- Configure ADC-- Step 1: ADC input pin setup pin_AN0_direction = input        
              -- Set A0 to analog input ADCON1_PCFG = 0b000-- Step 2: Set VDD 
and VSS as VrefADCON1_VCFG0 = FALSE                            -- Vref+ is 
VDDADCON1_VCFG1 

Re: [jallib] adc average

2021-11-13 Thread Rob CJ
Hi Vasile,

Thanks for the update. I found something strange. Given the code below.

include 18f4550

var byte i = 0

if (i == 100) then
  _error "Is 100"
end if

When I compile this I get:

jal jalv25r6 (compiled Oct 29 2021)
generating p-code
16858 tokens, 151522 chars; 3221 lines; 3 files
generating PIC code pass 1
generating PIC code pass 2
0 data accesses checked, 0 errors
1 skips checked, 0 errors
writing result
d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "Is 100"
1 errors, 0 warnings
The terminal process "c:\jallib\compiler\jalv2_64.exe 
'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'" 
terminated with exit code: 1.

Which is not correct. Same happens when you replace it with _warn but then it 
is generated as warning.

But when I have this program:

include 18f4550

var byte i = 0

if !defined(i) then
  _error "i is not defined"
end if

I get:

jal jalv25r6 (compiled Oct 29 2021)
generating p-code
16858 tokens, 151533 chars; 3221 lines; 3 files
generating PIC code pass 1
generating PIC code pass 2
0 data accesses checked, 0 errors
0 skips checked, 0 errors
writing result
Code area: 6 of 32768 used (bytes)
Data area: 1 of 2048 used
Software stack available: 2046 bytes
Hardware stack depth 0 of 31
0 errors, 0 warnings

Which is correct because when I change i to j the output is:

jal jalv25r6 (compiled Oct 29 2021)
generating p-code
16858 tokens, 151533 chars; 3221 lines; 3 files
generating PIC code pass 1
generating PIC code pass 2
0 data accesses checked, 0 errors
0 skips checked, 0 errors
writing result
d:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal:6: "i is not defined"
1 errors, 0 warnings
The terminal process "c:\jallib\compiler\jalv2_64.exe 
'd:\PIC\Compiler\Test\2021\ADC_in_array\Test.jal', '-s', 'c:\jallib\lib'" 
terminated with exit code: 1.

So not sure why this happens but is seems to be not OK.

Kind regards,

Rob


Van: jallib@googlegroups.com  namens vsurducan 

Verzonden: zaterdag 13 november 2021 08:08
Aan: jallib@googlegroups.com 
Onderwerp: Re: [jallib] adc average

Hi Rob,
I think you will not find any issue, please don't bother. The code works now 
(without interrupts), I had a multiplication error which is not part of the 
code.
My original test used  tmr0 interrupt and USB_serial, the average measurements 
should happen in 400us intervals and it seems something went wrong because the 
values are not those expected.

About the test procedure, I've loaded the ADRESH and ADRESL with constant 
values, without using any ADC_read procedure. Then tried to test the average 
procedure using _ERROR.  When the compiler finds the line containing _ERROR it 
reports an error no matter if the condition is true or false. Did I use it in 
the wrong way?
A very old version of the JAL compiler used a pragma_test (or something like 
that) previously to start a testing procedure. The result was delivered at 
compile time.
thank you,


On Fri, Nov 12, 2021 at 11:37 PM Rob CJ 
mailto:rob...@hotmail.com>> wrote:
Hi Vasile,

If I want to test this I need to create a program that does not use your 
one_ch_ad_read routine. So if I use the standard adc library the program looks 
like this. Is this program giving the same problem for you (I do not know which 
PIC you are using but it seem to be an 18F)?

About the error and warning. They are only created at compile time and I am not 
sure what voltage is at the time you compile the the program. I am also not 
sure if this works for variables.


include 18f4550
--
pragma target clock 48_000_000
-- magical statements: using a 20MHz Xtal, you can run @48MHz !
pragma target PLLDIVP5
pragma target CPUDIVP1
pragma target USBDIVP2
pragma target OSC   HS_PLL

pragma target WDT  control  -- watchdog
pragma target LVP  enabled  -- allow Low Voltage Programming
pragma target MCLR external -- reset externally

WDTCON_SWDTEN = off -- no watchdog

-- We'll start to set all pins as digital
-- then, using ADC lib, we'll configure needed
-- ones as analog.
enable_digital_io()

const sample_nr  = 8  ; buffer size dimension
var word voltage1_a[sample_nr] ; sample array
var word one_ch_ad_read, ch0_adc_value
var word voltage1 = 0 ; the average value we need
const word c256 = 256


-- Configure ADC
-- Step 1: ADC input pin setup
pin_AN0_direction = input
-- Set A0 to analog input
ADCON1_PCFG = 0b000
-- Step 2: Set VDD and VSS as Vref
ADCON1_VCFG0 = FALSE-- Vref+ is VDD
ADCON1_VCFG1 = FALSE-- Vref- is VSS
-- Step 3: Use Fosc/64 as ADC clock when using a 48 MHz target clock, see 
datasheet
ADCON2_ADCS = 0b110
-- Now we can include the library
include adc
-- And initialize the whole with our parameters
adc_init()

var byte i
  for 8 using i loop
   ch0_adc_value = adc_read_high_res(0) ; compute result
   voltage1_a [i] = ch0_adc_value ; store sample
   voltage1 = voltage1 + voltage1_a[i] ; do a sum of all