skraceni kurs ucenja picbasica

Rasprava o PIC mikrokontrolerima, PIC projekti i drugo vezano za PIC-eve...

Moderators: pedja089, stojke369, [eDo], trax

Post Reply
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: skraceni kurs ucenja picbasica

Post by pedja089 »

Mclr off disable ili sta vec pise... To je sve... Jedino sto na easypic 5 moras prebaciti jumper J7 na I/O...
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

Pozdrav svima danima pokusavam da ispisem nesto na displeju radim sa 16f877 al neide dal neko moze da mi kaze gde gresim u sledecem kodu simulacije radim u protesu:

Code: Select all

define osc 4
adcon1 = 7
DEFINE LCD_BITS 8
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_LINES 2
pause 100 
lcdout $fe,1, "ZDRAVO"
end
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: skraceni kurs ucenja picbasica

Post by pedja089 »

DEFINE LCD_BITS 8
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

Pa stavijo sam 8 jer je 16f877 8 bitni kako treba biti?
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

Ako se misli ta treba 4 posto se koristi samo D1,D2,D3,D4
sada sam stavijo:
DEFINE LCD_BITS 4
i opet nece.
Maki
Odlično uznapredovao
Odlično uznapredovao
Posts: 766
Joined: 02-07-2012, 12:54

Re: skraceni kurs ucenja picbasica

Post by Maki »

A definiranje portova ? TRISA i TRISB ? Makar u ovom slucaju ne koristis porta neg samo portb i k tome ga koristis kao izlazni. Probaj dodadti TRISB = 0
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

Usmeo sam nije nije rw bilo na masi.Jedno pitanje kako mogu nepoznate pokazivati na displeju?
naprimer x=2,y=16
kako mogu u istom redu ispisati x i y?
Maki
Odlično uznapredovao
Odlično uznapredovao
Posts: 766
Joined: 02-07-2012, 12:54

Re: skraceni kurs ucenja picbasica

Post by Maki »

Evo kao primjer lcdout $fe,1 DEC x
EDIT:
Tek sam sad skuzio da trebas u istom redu...
lcdout $fe,1,dec y, dec x
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

Uspeo sam hvala,jos jedno pitanje posto nece kako sam ja zamislio treba a i b da ispise u gornjem redu a c u donjem gde gresim?

Code: Select all

define osc 4
adcon1 = 7
a var word
b var byte 
c var byte
a=500
b=100
c=200
DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_LINES 2
pause 100 
lcdout $fe,1,dec a, dec b
lcdout $fe,2,dec c
end

nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

Uspeo sam u svakom slucaju mnogo hvala.
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: skraceni kurs ucenja picbasica

Post by pedja089 »

Malo vise citaj help, i sta je napisano ovde... Odgovor na sva tvoja pitanja je vec nekoliko puta napisan ovde, a pise i u helpu...
Generalno pazljivije citaj... Ako ne znas engleski, pocni da ucis uz neki prevodilac...
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

Znam solidno engleski,a nasao sam i na forumu lepo pise
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: skraceni kurs ucenja picbasica

Post by pedja089 »

Odlicno... Samo onda jos da naucis da citas :wink:
Branez
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 457
Joined: 22-04-2008, 16:27
Location: Maribor(SLO) Koprivnica(HR)
Contact:

Re: skraceni kurs ucenja picbasica

Post by Branez »

nemanjans wrote:Znam solidno engleski,a nasao sam i na forumu lepo pise
pedja089 wrote:Odlicno... Samo onda jos da naucis da citas :wink:
Al' dobro znaš isprobavati Pedjino strpljenje. :roll:
Real Radios Glow in the Dark!
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

haha soruy pedja hvala u svakom slucaju
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

E ovo nema nigde pazljivo sam citao.Pitanje:zasto posto treba mi kristal od 20mhz kad u proteusu stavim na pic 16f877 u proptisu da je kristal 20 mhz displej neradi a na 4mhz radi nomalno
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: skraceni kurs ucenja picbasica

Post by pedja089 »

Zato sto ti tajming nije dobar... I to ima opisano, samo malo na drugom mestu. PBP moras naznaciti koji oscilator koristis, da bi on mogao da izracuna pauze.
A kako se to radi, potrazi malo...
Vec si koristio to u kodu, iako nije moralo...
nemanjans
Penjem se :)
Penjem se :)
Posts: 67
Joined: 08-12-2012, 15:52

Re: skraceni kurs ucenja picbasica

Post by nemanjans »

ajde molim te pomoizi mi sta da izmenim def osc 4 tako je u datasetu dali tu treba 20 ili?
Branez
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 457
Joined: 22-04-2008, 16:27
Location: Maribor(SLO) Koprivnica(HR)
Contact:

Re: skraceni kurs ucenja picbasica

Post by Branez »

Image
Real Radios Glow in the Dark!
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: skraceni kurs ucenja picbasica

Post by pedja089 »

Au... Zajebo si se gadno... DEFINE OSC 4, ni za jedan kontroler ne pise ni u jednom datasheetu.
Veruj mi da ti pomazem mnogo vise nego sto mislis. Time sto te teram da sam dolazis do zakljucaka.
Evo ja cu stisnuti F1 umesto tebe, pa procitaj ovde:
DEFINE OSC 4 'Oscillator speed in MHz: 3 4 8 10 12 16 20 24 25 32 33 40
Iz manuala

Code: Select all

By default, the PICBASIC PRO Compiler generates programs intended to
be run on a PIC MCU with a 4MHz crystal or ceramic resonator. All of
the time-sensitive instructions assume a 1 microsecond instruction time
for their delays. This allows a PAUSE 1000, for example, to wait 1
second and the SERIN and SEROUT command’s baud rates to be
accurate.
There are times, however, when it would be useful to run the PIC MCU at
a frequency other than 4MHz. Even though the compiled programs move
along at a pretty good clip, it might be nice to run them even faster. Or
maybe it is desirable to do serial input or output at 19,200 baud or higher.
PICBASIC PRO programs may be run at clock frequencies other than
4MHz in a couple of different ways. The first is to simply use an oscillator
other than 4MHz and don’t tell PBP. This can be a useful technique if
you pay attention to what happens to the time dependent instructions.
If you wish to run the serial bus at 19,200 as described above, you would
simply clock the microcontroller with an 8MHz crystal rather than a 4MHz
crystal. This, in effect, makes everything run twice as fast, including the
SERIN and SEROUT commands. If you tell SERIN or SEROUT to run at
9600 baud, the doubling of the crystal speed will double the actual baud
rate to 19,200 baud.
However, keep in mind commands such as PAUSE and SOUND will also
run twice as fast. The PAUSE 1000 mentioned above would only wait .5
seconds with an 8MHz crystal before allowing program execution to
continue.
The preferred technique is to use a different oscillator frequency and tell
PBP of your intentions. This is done through the use of a DEFINE.
DEFINE is used to tell PBP to use something other than its defaults.
Normally, PBP defaults to using a 4MHz oscillator. Adding the statement:
DEFINE OSC 8
near the beginning of the PICBASIC PRO program tells PBP an 8MHz
oscillator will be used instead. 
Telling PBP the oscillator frequency allows it to compensate and produce
the correct timing for COUNT, DEBUG, DEBUGIN, DTMFOUT, FREQOUT,
HPWM, HSERIN, HSERIN2, HSEROUT, HSEROUT2, I2CREAD, I2CWRITE,
LCDIN, LCDOUT, OWI,N OWOU,T PAUS,E PAUSEU, S SERI, N SERIN2,
SEROU, T SEROU,T 2 SHIFT,I N SHIFTO,U T SOU, ND XIN and XOUT.
Changing the oscillator frequency may also be used to enhance the
resolution of the PULSIN, PULSOUT and RCTIME instructions. At 4MHz
these instructions operate with a 10 microsecond resolution. If a 20MHz
crystal is used, the resolution is increased 5 times to 2 microseconds.
For PBP and PBPW (not PBPL), there is a tradeoff, however. The pulse
width is still measured to a 16-bit word variable. With a 2 microsecond
resolution, the maximum measurable pulse width would be 131,070
microseconds. For PBPL, a 32-bit variable may be used to allow
measurement of very long pulses.
Going the other direction and running with a 32.768kHz oscillator is
problematic. It may be desirable to attempt this for reduced power
consumption reasons and it will work to some extent. The SERIN and
SEROUT commands will be unusable and the Watchdog Timer may cause
the program to restart periodically. Experiment to find out if your
particular application is possible at this clock speed. It doesn’t hurt to try.
Post Reply