1 The very beginning: JAL FAQ version 1.0 March 23, 2008 1
1.1 JAL? PIC? Where do I start? 1
1.2 Where to get JAL? 1
1.3 Which PIC? 2
1.4 What's all this JAL then? 2
1.5 I've downloaded JAL, now what? 3
1.6 Command line? Bach files? I want a nice GUI! 3
1.7 I'm a Newbie: how do I access EEPROM/PWM/flash? 4
1.8 Glossary 4
1.9 JAL books
2 The programmer 4
2.1 Which programmer to use? 4
2.2 LVP: enable or not? 4
2.3 LVP programming for lazy JAL users 4
2.4 Is JAL compatible with any bootloader 4
3 Hardware 4
3.1 LCD: Using HD44780 display 4
3.2 LCD: Using HD44780 on port_a 5
3.3 LCD: Reset Problem Fix 5
3.4 Some pin on port_a isn't doing what it is supposed to do! 5
3.5 pin_a4 does not go high 5
4 Software 5
4.1 LCD: How can I display digits and other characters? 5
4.2 LCD: How can I display numbers bigger than 255? 6
4.3 Using already defined variables 6
4.4 Error: operator not known for these operands: *, /, >>, 6
4.5 How to write an ISR 6
4.6 Do NOT use ISR for buttons 6
4.7 I2C routines 7
5 Posting rules 7
5.1 General posting rules: 7
5.2 Does this program work? 8
5.3 My circuit doesn't work! 8
5.4 My timer doesn't run! 8
6 Bugs and features 8
6.1 print_decimal_x bug 8
6.2 Does this lib exist? 8
6.3 Editing the standard libs? 8
7 How you can help 9
8 Contributors 9
1 The very beginning: JAL FAQ version 1.0 March 23, 2008
1.1 JAL? PIC? Where do I start?
Come back when you have read it all.
1.2 Where to get JAL?
JAl V2 homepage:
Libraries option 1:(limited number of supported PICs, compatible with JAL books)
*Windows EXE file + libraries + editor ("starterpack"):
Libraries option 2: (very large number of supported PICs, not compatible with JAL books)
If you have grabbed some older examples from the web please
check if they are written for JAL 0.4x. These will not run on JALv2.x without modification.
1.3 Which PIC?
>I want to order some free samples offered by Microchip. What PIC chips
>do you recommend for hobby use and why?
16F877: huge, can do all.
12F675, small neat. You'll run out of pins quickly.
16F628, 16F819 fine workhorses for a specific job. 628 has UART, 819 has A/D.
read the entire page
1.4 What's all this JAL then?
JAL is a high-level language for a PIC microcontroller. It looks like:
if count % 10 == 0 then
;; 093 : if count % 10 == 0 then
if_16915_th: ; 007B
1.5 I've downloaded JAL, now what?
It depends on your OS. If you downloaded the starterpack unzip it and follow the instructions inside.
Windows: Go to the command line by Start/Run/command
type jal <enter> on the command line.
>Bad command or file name
>jal 00.04-55 (djgpp)
>The jal command line can contains source files and options. An option
>starts with a '-', everything else is a source file. Options are:
>-t or -tN : test
1) bad. Go find jal.exe.
Switch back to Windoze and hit flag-f or do Start | Find | Files or Folders or Start | Search | All Files and Folders and search for "jal.exe"
Search the entire hard drive, starting at the root and include subdirectories
When you find it, either beat a PATH to it or make a BATCH file. Check your path by typing �set� on the command line.
Make a �jal.bat� file that contains:
c:\some_jal_dir\jal.exe -sc:\some_jal_dir\lib %1 %2 %3 %4 %5 %6 %7 %8 %9
and save it somewhere in your PATH.
Changing the path in XP is in Start | Control Panel | System | Advanced tab| Environment Variables | PATHEXT . Add �;C:\some_jal_dir to this.
(should this be added to the README?)
2) good. Now move to the directory that contains the libraries and type:
jal b628-2.jal <enter>
1.6 Command line? Bach files? I want a nice GUI!
Here are some:
And this one includes a simulator:
1.7 I'm a Newbie: how do I access EEPROM/PWM/flash?
Blink a LED first. Go here: http://www.voti.nl/blink/index.html
LVP low voltage programming
ICSP in circuit serial programming
JAL just another language
PIC peripheral interface controller
POSIX Unix, Linux, FreeBSD, Solaris, AIX, HP-UX, etc
MCLR memory clear, resets PIC. does not clear memory
POR power on reset. does clear memory
ISR interrupt service routine
1.9 JAL books
Dutch: PIC Microcontrollers, 50 projecten voor beginners en experts
Dutch: Kunstmatige Intelligentie - breng uw microcontroller tot leven!
English: PIC Microcontrollers, 50 projects for beginners and experts
English: Artificial Intelligence - 23 projects to bring your microcontroller to life
Greek: PIC Microcontrollers, 50 projects for beginners and experts
Spanish: Microcontroladores PIC, 50 Proyectos para Principiantes y Expertos
German: PIC-Mikrocontroller, 50 Projekte f�r Anf�nger und Fortgeschrittene
Turkish: JAL ile PIC programlama
Romanian: Microcontrolere Pentru Toti
2 The programmer
2.1 Which programmer to use?
The best is Wisp648, available here: http://www.voti.nl/shop/catalog.html?A-Wisp648
It will even program the 12F with internal /MCLR.
2.2 LVP: enable or not?
Depends on your programmer. Does it supply 13V to /MCLR? If not, turn LVP on. Don't use the pin in your application. If your programmer does supply 13V, turn LVP off and the pin becomes available. A good ICS programmer let you re-use the programming pins in your application as well. LVP is enabled/disabled in the configuration word, a.k.a. as "fuses".
2.3 LVP programming for lazy JAL users
LVP pin must be grounded using a 10K resistor. LVP bit from configuration word must be either factory set, either using a HVP programming to enable a LVP Disabling LVP is possible only after a HVP modification of the configuration word.
2.4 Is JAL compatible with any bootloader
Yes, for example:
Shane Tolmie (PIC16 bootload)
Claudiu Chiculita (Tiny PIC Bootloader)
3.1 LCD: Using HD44780 display
There are quite a few gotchas regarding the use of a LCD with JAL. Here are some random blurbs: * Unless there is a good reason, drive the LCD in 4-bit mode, this uses six pins instead of ten. * Copy the HD44780*.jal files into your project directory. Then these can be edited with no worries. (JAL will use "local" files before using the original libraries.) * Edit the HD44780p file to represent the pins your LCD is using, and also edit the HD44780 lib, it contains the various chipset timings (refer to your LCD datasheet.) * If the LCD is not working at all, switch the PIC crystal to a much slower one (without reprogramming) and try it again. If it works now, then the problem is a timing issue. * The HD66712 LCD is supposed to be compatible with the HD44780, but we are not 100% sure of this. If you have problems, try slowing down the PIC, it could be timing-related.
3.2 LCD: Using HD44780 on port_a
If not using analog inputs, it is possible to move the LCD to port_a (and free up port_b for interrupts) but there are two gotchas: RA4 is open-collector (cannot drive high, needs a pull-up resistor) and the display will not work until all the following is declared in your program, in order:
pin_c7 = on -- turn on LCD power
include hd447804 -- includes HD44780, HD44780p, jdelay, jpic libs
port_a_direction = all_output -- port_a must be all outputs (LCD)
HD44780_clear -- reset display
3.3 LCD: Reset Problem Fix
Sometimes the LCD will not reset properly if the PIC is reset via the MCLR pin... The best workaround is to power the LCD directly from a PIC pin, and turn this on in software.
3.4 Some pin on port_a isn't doing what it is supposed to do!
Did you disable the analog functions on port_a? Some PICs have analog inputs or comparators that are enabled by default. If you are trying to use one of those pins as normal digital pins they will not work.
3.5 pin_a4 does not go high
pin_a4 cannot go high. You must pull it up with an 1k or 10k resistor depending on the
current your circuit needs.
4.1 LCD: How can I display digits and other characters?
Typically letters can be displayed such as:
HD44780 = "L" HD44780 = "e" HD44780 = "t"
HD44780 = "t" HD44780 = "e" HD44780 = "r"
There are two ways to display numbers. One, if you look at your LCD datasheet, it should give both 4-bit (MSB, LSB) nibbles for each character it can display. If you concatenate the two values, the result is the character for that digit. For instance, if you wanted to display 524, this would work:
HD44780 = 0b0011_0101
HD44780 = 0x32
HD44780 = 52
The keen eye will notice that "4" = "52" and so just adding dec 48 to your number will allow numbers to be displayed. Special characters are no different, just use the appropriate values from your datasheet. The other (easier) method to display numbers is to use a library. Eur van Andel has made a "j_print.jal" library at [url]http://groups.yahoo.com/group/jallist/files/Eur_van_Andel/> which will display 1,2, or 3 digits (up to decimal 255) on a LCD.
4.2 LCD: How can I display numbers bigger than 255?
Several routines are included with JAL for manipulating values larger than 255 directly, and while it is indeed possible to use fixed-point math and various HD44780 calls to do this, it is far beyond the scope of this F.A.Q. It might be easier to use floating-point math. Numbers from -9999.9999 to +9999.9999 can now be displayed on a LCD with one call, thanks in large part to Ziya Erdemir. The library is located at
[url]http://groups.yahoo.com/group/jallist/files/heliosstudios/"> Ziya`s files are located at
4.3 Using already defined variables
Do not use already defined variables (like nodes numbers): var byte foul = _860
Read the ASM file to get an idea which variables the compiler generates. Don't use variables that start with numbers.
4.4 Error: operator not known for these operands: *, /, >>,
For some 0.4.x JAL compilers, A number of operators are not implemented in JAL itself, but in a separate library called JRTL.jal. (Or JRTL16.jal.) So you need to include JRTL.jal as one of the first libraries in your program.
4.5 How to write an ISR
Don't put anything in an ISR that generates unknown assembler code. Don't use *, / or other stuff. Don't call other procedures unless you really know what you are doing. 95% of the time an ISR is not needed. Read the resulting assembler in the .ASM file and check that no weird things happen.
4.6 Do NOT use ISR for buttons
A button can be read every 100ms and that is a lot of instructions. Just check for the button every once in a while. Every 200ms is fine too. Just check the button once, no need for debouncing. Yes, the user has to hold the button more than 100ms. Believe me, it is impossible to press a button for less than 100ms.
Remember: an ISR is only used for External Events that have to be dealt with Quickly.
4.7 I2C routines
Jal has an I2C routine that works. Adapt it to your specific I2C chip. Some I2C debugging tips:
- Buy an oscilloscope. Debugging I2C without a scope is nightmare. If need be, use an extra PIC pin for triggering.
- If you do NOT have a scope, measure the current between the GND pin of your I2C IC and ground. Check first if the default current matches the datasheet. Now talk to the IC. If properly addressed, the IC will pull SDA low and this should be visible on you milliampere meter.
- If you have a scope, watch the SDA signal closely. You should be able to see a different low level of SDA during an ACK. This level comes from your IC, not the PIC. Congratulations, your IC is talking.
- No, JAL does not wait for a slave ACK. If it would and the address was wrong, it would be a long wait.
- I2C errors are often addressing errors. Check the datasheet again and if need be, read the byte from the scope.
5 Posting rules
5.1 General posting rules:
Please list you full name. It is nice for old farts like us to talk to a real person, instead of strange handles like: goldeagle98201@... or fun_4_me_now20012000@.... If you want to control an printing press for an illegal newspaper, take an alias like Geoff Nyarota or Veera Prateepchaikul. We will help you with the JAL code for the press.
Indicate your PIC level: did you blink a LED? Work with a HD44780 LCD display? Tell us which PIC you use and which programmer.
A very good example is this:
>My name is Eddy and I am new to the list and the JAL language.
>I am 34 years old and live in the Netherlands.
>After about 15 years I picked up electronics as a hobby when I discovered the
>PIC a month ago.
>I am experimenting with PICs and JAL, and lurking this list for a month now
>and did a couple of projects successful (including blinking the led, Eur).
>I am puzzled over the basics with bits and bytes in JAL.
If your program doesn't work, post it. If you use special libs, post these too. Do not attach files, yahoo strips them. Do not post files in the files section, unless you really think other people can use them.
I've posted my non working program and 15 non-standard libs in here, please look at it and tell me why it does not work?
Chips 'R Us has a new A/D converter with a modified I2C protocol. I've posted a lib here [URL]. I have tested it on a 16F877, 12F675 and 16F628 with success.
5.2 Does this program work?
Beats me. Did you compile it without errors? Did you flash it into a PIC? What happened? Post the program and tell us the PIC behavior. Tell us what the PIC should have done. No, we will NOT look at your program until you compiled it, flashed and run it. The compiler is perfectly able to display error msgs about your code, thank you.
5.3 My circuit doesn't work!
Did you blink a LED first? If not, check here: http://www.voti.nl/blink
If so, post a schematic, preferably in ASCII. There are programs to make ASCII circuits.
If you must use a schematics program, try Eagle. It is free and understood by most readers.
http://www.cadsoftusa.com (or http://www.cadsoft.de)
5.4 My timer doesn't run!
Read the datasheet, sleep with the datasheet, dream the datasheet, be the datasheet.
Here they are:
6 Bugs and features
6.1 print_decimal_x bug
Yes, print_decimal_x has a bug. It comes few and far between and nobody has been able to reproduce it reliably. You will be a revered as a saint when you can.
6.2 Does this lib exist?
I have this Yoyodyne Frobulator, with 6 pins and it uses the Pecosoare protocol. Did somebody write a driver for it?
Maybe. Check the files section of the jallist home page. No, you can't search this section.
6.3 Editing the standard libs?
Short answer: don't do it. Others won't be able to understand or compile your program. If you must (by using different pins), put all the pin assignments in one file and include the libs from there.
7 How you can help
Did you write a program or library that might be interesting to others? Post it in the files section, but please with a clear description as to what your projects does. If you have a website with JAL projects post a link in the links section.
Wouter van Ooijen
Bert van Dam
Eur van Andel (maintainer of this FAQ)