Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F88 usart troubles: WVProfessor

Status
Not open for further replies.
The 16F88 cannot do I²C master mode in hardware. If you switch to a 16F87x or a 18F1320 (18 pin) etc then you can do it in hardware.

Mike.
 
blueroomelectronics said:
The 18F1320 doesn't have a MSSP, it does have a EUSART.
You are correct, over the last month I've played around with so many 18 series chips with C18, Swordfish etc. I got confused and forgot that I used Swordfish's software I²C routines.:eek:

Mike.
 
Pommie said:
You are correct, over the last month I've played around with so many 18 series chips with C18, Swordfish etc. I got confused and forgot that I used Swordfish's software I²C routines.:eek:

Mike.

Swordfish is really something. Does your GLCD work with their modules?
 
What is the best part?

If I have to change parts I might as well look for the best one to do the whole job.
I want to make a small board that can run alone gathering a large number of analog measurements and then when connected send it over a serial port.

So I need a uart, an I2C port, an A/D and a clock.

I figured the internal clock is good enough.
A 10 bit A/D is fine.
The I2C is to talk to an EEPROM but maybe I need to switch to a USB memory stick.
I have a bunch of 20 pin narrow DIP wire wrap sockets.

I am an analog guy so I don't need help with that part.

This is just a home project so I hope to keep the cost to under $10.
 
Haven't tried GLCD with swordfish. That's something I should try, Unicorn+GLCD+Swordfish.

Speaking of GLCDs, I have just got my analogue clock working on the 16F886 in asm. I think it looks rather good.

Mike.
 
Last edited:
WVProfessor said:
If I have to change parts I might as well look for the best one to do the whole job.
I want to make a small board that can run alone gathering a large number of analog measurements and then when connected send it over a serial port.

So I need a uart, an I2C port, an A/D and a clock.

I figured the internal clock is good enough.
A 10 bit A/D is fine.
The I2C is to talk to an EEPROM but maybe I need to switch to a USB memory stick.
I have a bunch of 20 pin narrow DIP wire wrap sockets.

I am an analog guy so I don't need help with that part.

This is just a home project so I hope to keep the cost to under $10.


The simplest way would be a bitbanged I²C serial EEPROM and use the hardware USART. If you want an accurate clock then you need a crystal or an external (I²C) clock. How often do you need to take a measurement? If you switch to a 18F1320 and use Swordfish basic I could probably knock the code together relatively quickly. I already have a board with a 18F1320+LCD+DS1307 RTC.

Mike.
 
Pommie said:
Haven't tried GLCD with swordfish. That's something I should try, Unicorn+GLCD+Swordfish.

Speaking of GLCDs, I have just got my analogue clock working on the 16F886 in asm. I think it looks rather good.

Mike.

I have no idea what those words mean. Can you give me the long introduction?
Thanks.
 
WVProfessor said:
I have no idea what those words mean. Can you give me the long introduction?
Thanks.
I thought it was plainly obvious that I was answering Bill's post. I answered your post immediately after that - I even quoted you. Did you not notice? Is WV some place where English is a second language?

Mike.
 
Pommie said:
The simplest way would be a bitbanged I²C serial EEPROM and use the hardware USART. If you want an accurate clock then you need a crystal or an external (I²C) clock. How often do you need to take a measurement? If you switch to a 18F1320 and use Swordfish basic I could probably knock the code together relatively quickly. I already have a board with a 18F1320+LCD+DS1307 RTC.

Mike.

I have the feeling that I am re-inventing the wheel.
I just downloaded the free Swordfish.
The 18F1320 price is right.
I was going to make a measurement only once a minute.
I am not yet ready to give up a pin for the clock although I have a bucket full of crystals and crystal oscillators. I don't know what accuracy I can get or want.
I was going to use timer 0 or timer 1 in the 16f88 but have no idea how the civilized world designs the code.
I will try measuring battery voltage and temperature outside in the yard.
 
Pommie said:
I thought it was plainly obvious that I was answering Bill's post. I answered your post immediately after that - I even quoted you. Did you not notice? Is WV some place where English is a second language?

Mike.

I just saw some interesting buzz words. I see some posts today that I didn't see yesterday. What is Unicorn?

I guess GLCD is a graphic LCD. I got a bad feeling about LCDs after some underwater tests. They came apart from the board.
If I need a display I have a bunch of seven segment LED digits. They will need their own power supply. Tough decisions.

I don't know if I would need a real time clock or just something that makes slow square waves that I could sync to. I have a bunch of old TTL dip chips.

I will look at swordfish and MPLAB. I am fair with quickbasic.

Thanks to all for help and ideas.
 
WVProfessor said:
I have the feeling that I am re-inventing the wheel.
I just downloaded the free Swordfish.
The 18F1320 price is right.
I was going to make a measurement only once a minute.
I am not yet ready to give up a pin for the clock although I have a bucket full of crystals and crystal oscillators. I don't know what accuracy I can get or want.
I was going to use timer 0 or timer 1 in the 16f88 but have no idea how the civilized world designs the code.
I will try measuring battery voltage and temperature outside in the yard.

Swordfish is just about the best BASIC for PICs I've ever used, make sure you try out the free IDE too. It's 256byte SE limit (the free version) is a perfect fit for the 18F1320. You'll get about 1% accuracy with the internal RC clock, a crystal will give you much better accuracy.
Your project should be pretty easy to do in BASIC.
PS the 18F1320 also has a built in low voltage detector if you're running off batteries. Also keep the crystal as slow as possible for longest battery life.
 
New problem

It is not possible to move my messages to page 1 because they are bigger (in total) than one whole page. Actually 160h in size. Most of my code is message text!

Which approach is better?
Break up the messages and place them in the middle of some pages, with code in between.
Or take the bull by the horns and do the full pch addition, (which means fix things when pcl rolls over)?

I am still in a 16F88.
Code:
               00192 ;********************************************************************
               00193 ;* Message table input is from pcl, returns a character in w.   *
               00194 ;********************************************************************
               00195 ; put in low memory since we can't cross a page boundary
0061 3907      00196 Msg     ANDLW   0x07    ; restrict jump size
0062 0782      00197         addwf   pcl,f   ; computed jump
0063 286A      00198         goto    Msg1
0064 28EF      00199         goto    Msg2
0065 2905      00200         goto    Msg3
0066 2922      00201         goto    Msg4
0067 2950      00202         goto    Msg5
0068 297E      00203         goto    Msg6
0069 29AC      00204         goto    Msg7
               00205 
006A 0823      00206 Msg1    MOVF    inx,w           ; get index
006B 0782      00207         ADDWF   pcl,f           ; point to char
006C 340D 340A 00208         DT      CR,LF,"Commands are:",CR,LF
006E 3443 346F
0070 346D 346D
0072 3461 346E
0074 3464 3473
0076 3420 3461
0078 3472 3465
gpasm-0.12.1 beta               osa.asm     4-8-2008  04:12:54           PAGE  5


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE
 
007A 343A 340D
007C 340A
007D 3453 3420 00209         DT      "S for general state data,",CR,LF 
007F 3466 346F
0081 3472 3420
0083 3467 3465
0085 346E 3465
0087 3472 3461
0089 346C 3420
008B 3473 3474
008D 3461 3474
008F 3465 3420
0091 3464 3461
0093 3474 3461
0095 342C 340D
0097 340A
0098 3454 3420 00210         DT      "T for time, D to download, ",CR,LF
009A 3466 346F
009C 3472 3420
009E 3474 3469
00A0 346D 3465
00A2 342C 3420
00A4 3444 3420
00A6 3474 346F
00A8 3420 3464
00AA 346F 3477
00AC 346E 346C
00AE 346F 3461
00B0 3464 342C
00B2 3420 340D
00B4 340A
00B5 3441 3420 00211         DT      "A to toggle A/D converter,",CR,LF
00B7 3474 346F
00B9 3420 3474
00BB 346F 3467
00BD 3467 346C
00BF 3465 3420
00C1 3441 342F
00C3 3444 3420
00C5 3463 346F
00C7 346E 3476
00C9 3465 3472
00CB 3474 3465
00CD 3472 342C
00CF 340D 340A
00D1 3449 3420 00212         DT      "I to change sample interval. ",NULL
00D3 3474 346F
00D5 3420 3463
00D7 3468 3461
00D9 346E 3467
00DB 3465 3420
00DD 3473 3461
00DF 346D 3470
00E1 346C 3465
gpasm-0.12.1 beta               osa.asm     4-8-2008  04:12:54           PAGE  6


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE
 
00E3 3420 3469
00E5 346E 3474
00E7 3465 3472
00E9 3476 3461
00EB 346C 342E
00ED 3420 3400
               00213                 
00EF 0823      00214 Msg2    MOVF    inx,w           ; get index
00F0 0782      00215         ADDWF   pcl,f           ; point to char
00F1 340D 340A 00216         DT      CR,LF,"A/D is toggled ",CR,LF,NULL
00F3 3441 342F
00F5 3444 3420
00F7 3469 3473
00F9 3420 3474
00FB 346F 3467
00FD 3467 346C
00FF 3465 3464
0101 3420 340D
0103 340A 3400
 
Check my 8x8 LED matrix tutorial, which uses large tables for both the character font, and the scrolling messages. It's probably easier to do it that way, rather than have separate parts in different pages.
 
Nigel Goodwin said:
Check my 8x8 LED matrix tutorial, which uses large tables for both the character font, and the scrolling messages. It's probably easier to do it that way, rather than have separate parts in different pages.

I got to and then got lost in the list. That is a lot of stuff, I hope to read some day. Which one?
 
WVProfessor said:
I got to and then got lost in the list. That is a lot of stuff, I hope to read some day. Which one?

Here:
 
Sneaky bug

I have been held up for three weeks hunting a bug in my code.
It turns out that after
loading pclath with 1
addwf pcl,f
retlw 'Z'

when I get back in the calling routine pclath still has the 1 in it.
Then when I do another addwf pcl,f it goes to page 1 instead of the intended page 0 address. I thought pclath was reset by the addwf pcl,f.

It took a simulator to find that one.

I got the 10 bit A/D going in record time. It was easy.
I am shipping the bits out as three characters.
By adding 30h to each 4 bit group I get numbers from 0 to 9 and then instead of ABCDEF it shows up as :;<=>?
This is in accordance with the ascii table, pretty crude. I plan to fix it back in the computer using quickbasic. I bet there is a better way.

Thanks again to all.
 
The 800 address problem.

Once again the 16F88 has a nasty design problem.

If you write code that crosses the 800 address barrier it fails.

Suppose
org 7FE nop
7FF nop
800 nop
801 return

The instruction at 800 is never executed.
Instead of going from 7FF to 800 it goes from 7FF to 0 or something equally insane. This is an outrageous design and a well kept secret.
Now I can only use half of my instruction memory and the other half is empty.
This is a mess. I bet only someone who has friends who research these things will ever find out how to get around this problem.

Rumor has it that there is a bunch of wierd code that gets around this, like putting something in PCLATH.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top