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.

where do i learn bout PIC ?

Status
Not open for further replies.
kupikupi said:
movlw D’25’
movwf SPBRG ;initialize SPBRG
movlw H’24’
movwf TXSTA ;initialize TXSTA
movlw H’90’
movwf RCSTA ;initialize RCSTA

i want to upload the USART codes into my PIC so that the PIC can communicate with the PC ... do i use the codes above??
could anyone help me to modify it so that i can upload it directly to the PIC??
im really at assembly and I'm learning it now.. but i need to use it tomorrow. please help me .. thanx

The codes above simply initialise the USART, it doesn't actually 'do' anything - you also don't give any clue as to what you want to do?. 'Communicate with the PC' is so vague as to be meaningless?.
 
The codes above simply initialise the USART, it doesn't actually 'do' anything - you also don't give any clue as to what you want to do?. 'Communicate with the PC' is so vague as to be meaningless?

sorry bout that... well .. for my project, there are 2 ways of uploading programs into the PIC one of them will be using a programmer called " pic start plus" i can only use it in the Uni lab, so , there is another way to upload program which is thru a serial port RS 232 using MAX 232 converter, but i was told that i cant upload a program directly without USART .. but how do i use USART??
 
kupikupi said:
The codes above simply initialise the USART, it doesn't actually 'do' anything - you also don't give any clue as to what you want to do?. 'Communicate with the PC' is so vague as to be meaningless?

sorry bout that... well .. for my project, there are 2 ways of uploading programs into the PIC one of them will be using a programmer called " pic start plus" i can only use it in the Uni lab, so , there is another way to upload program which is thru a serial port RS 232 using MAX 232 converter, but i was told that i cant upload a program directly without USART .. but how do i use USART??

You don't need to worry about the USART, what you need is a bootloader program, you use the PICStart Plus to program the bootloader into the PIC. You can then use a PC program (which will be provided with the bootloader, or even something as simple as Hyperterminal) to transfer programs via RS232 to the PIC.

There are various bootloader programs at https://www.microchipc.com/, I've never used the 18F ones, but the 16F ones are excellent!.
 
thanx nigel... but when do we need to use USART ?
USART is a hardware peripheral, which will take care of the transmission itself, so that your code can do somethnig else while you are sending/receiving.
Bootloader is a software routine that takes Bytes from USART and place them into Program memory...
this was fromm jay ...
u said i dont have to worry bout USART.. may i ask wat takes care of the transmission??
 
another question...
lets say i have a LED blinking program in my PIC, i want to upload a motor driving program ...
when i upload it ... do i have to do anything so that i wont overwrite the previous program or i just upload it and the bootloader will arrange it for me ?
 
kupikupi said:
another question...
lets say i have a LED blinking program in my PIC, i want to upload a motor driving program ...
when i upload it ... do i have to do anything so that i wont overwrite the previous program or i just upload it and the bootloader will arrange it for me ?

The bootloader takes care of the USART, all you need to do is provide suitable hardware (as in a MAX232 connected to the USART pins).

As I said, I've not used 18F bootloaders, but in the 16F the bootloader code is written at the very top of memory. Normal programs run in the lower parts of memory, so the bootloader code is out of the way. When you upload a new program, it overwrites the previous one, but the bootloader itself isn't touched (or shouldn't be!).

There's no reason not to overwrite the previous program, not doing so wouldn't achieve very much?.
 
so do u mean that the PIC can only take one program at once?
meaning that if i want the PIC to perform multi tasks , i have to combine all the programs into 1 ?? i cant separate the programs?? i'm really new with PIC, i dont know how it works.... :?
 
kupikupi said:
so do u mean that the PIC can only take one program at once?
meaning that if i want the PIC to perform multi tasks , i have to combine all the programs into 1 ?? i cant separate the programs?? i'm really new with PIC, i dont know how it works.... :?

Essentially yes!.

There's nothing to stop you writing a multi-tasking operating system if you so wished?, bear in mind even a PC doesn't multi-task at all well!, the Intel processors are very badly suited for it!.

But the small amounts of program memory available would waste too much of the OS, and not leave much available for programs. Bear in mind, this is a micro-controller, NOT a full blown computer with multi-megabytes of memory and gigabytes of hard disk.

However, it's hard to think of anything that would require such an OS?, the PIC's huge advantage is it's small size and speed, multi-tasking would cripple the speed, just as it does on (almost!) everything else.
 
i'm a little confused about the Tiny bootloader that Jay was talking about, is it a .hex file to program into the PIC or is it software like Mplab ?? from the previous post i understood that Tiny bootloader has the same function as Mplab(i used mplab to upload program into the PIC thru picstart plus,now i want to upload programs from home using serial port) so could i just use mplab instead of the the tiny bootloader ? is it the same ?? and i still need to upload a bootload .hex file into the pic thru picstart plus b4 i can do so right??
i went thru the tiny bootloader site and i cant find any bootloader .hex file. could anyine help me out here??how do u rite a bootloader hex file?
 
kupikupi said:
i'm a little confused about the Tiny bootloader that Jay was talking about, is it a .hex file to program into the PIC or is it software like Mplab ?? from the previous post i understood that Tiny bootloader has the same function as Mplab(i used mplab to upload program into the PIC thru picstart plus,now i want to upload programs from home using serial port) so could i just use mplab instead of the the tiny bootloader ? is it the same ?? and i still need to upload a bootload .hex file into the pic thru picstart plus b4 i can do so right??
i went thru the tiny bootloader site and i cant find any bootloader .hex file. could anyine help me out here??how do u rite a bootloader hex file?

The URL I posted earlier has source code for bootloaders, but to be honest, if you've got to ask you probably aren't capable of it? :cry:

But there's no need, they are many bootloaders you can download, any site with them on should explain what you need on the PC - even if it's just a simple terminal program.

I wouldn't expect MPLAB to perform this task?, it's basically an editor and simulator, with links to the MicroChip programmers (like the PICStart Plus) and the assembler MPASM.
 
so is it that i can only use mplab to upload program to the PIC thru microchip programmers.. and for uploading via serial port .. i will need bootloader together with the bootloader software?? the one shown below?? are all bootloaders the same ?? meaning that i can just download any bootloaders and run with this software, Tiny bootloader??
 

Attachments

  • bootloader.jpg
    bootloader.jpg
    23.2 KB · Views: 800
kupikupi said:
so is it that i can only use mplab to upload program to the PIC thru microchip programmers..

MPLAB is a development enviornment where the asm file is compiled/assembled into a HEX file. You can use either Microchip's programmers or other programmers or even build one yourself to send the HEX into the PIC. See here:

A home made programmer

kupikupi said:
.. and for uploading via serial port ..

This is an option that requires no programmer except a standard RS232 serial connection to the PC. Suitable for people who do not have access to programmers at home, like you are now.

kupikupi said:
i will need bootloader together with the bootloader software?? the one shown below?? are all bootloaders the same ?? meaning that i can just download any bootloaders and run with this software, Tiny bootloader??

All bootloaders are different. Of course they are if not why we have so many?

Every bootloader need a specific software to work. For some, that specific software is simply the terminal program like Hyperterm. For others, like TinyBootloader, you have to run it's software for it to work.
 
eblc1388 ... i got it .. very clear explanation ... so now ... since im using the tiny bootloader codes, i'll have to use the software tinybootloader provides.. thanx alot....

do u know how the IR module works with the PIC?? where is the receiver placed and where is the transmitter placed ?? wat components does the IR consist of and do i get it part by part or it's sold as 1 set?? if i use a joystick to control the direction of the motor .. how does a joystick send signal to the PIC?? and is the transmitter connected to the joystick ???
 
kupikupi said:
do u know how the IR module works with the PIC?? where is the receiver placed and where is the transmitter placed ??
The receiver is placed such that the IR beam from the transmitter can be seen.

kupikupi said:
wat components does the IR consist of and do i get it part by part or it's sold as 1 set??
IR transmitter is just a diode like LED. It sends out IR instead of visible light. You can "see" the beam if you view it using a camera phone.

The receiver is sold as a complete module, mostly with three pins. Two for supply and one for signal output. The signal is the ON/OFF pattern of IR beam.

kupikupi said:
if i use a joystick to control the direction of the motor .. how does a joystick send signal to the PIC?? and is the transmitter connected to the joystick ???
You'll need an interface between joystick and IR transmitter. You either build one or buy a cheap universal remote, use the internal components and wire the joystick switches to replace the original keys. You connect the receiver to one port pin of the PIC and using software to decode what command is being sent from the transmitter.
 
;*****************************************************************
title "PIC PowerBoard: Program pre PIC18F452"
subtitle "Version 1.00 (c) Jay.slovak 2005"
;*****************************************************************
list p=18F452 R=DEC ; wat is this for
#include <P18F452.INC>

ERRORLEVEL 2 ; is it neccesary to put this?

;********** Definovanie uzivatelskych registrov *******************
Fosc equ 20 ;Frekvencia Oscilatora v Mhz

ZDRZ0 equ D'000' ;
ZDRZ1 equ D'001'
ZDRZ2 equ D'002'


;********** Zaciatok pamati programu ******************************
ORG 0x0004 ; does it ont always start at 0?
GOTO INIT
;********** Inicializacia procesora *******************************
ORG 0x002A
INIT MOVLW h'07' ; some led blinking program
MOVWF ADCON1,a ; doesnt have this , will it still
; work??
CLRF PORTA
CLRF PORTB
CLRF PORTC
CLRF PORTD
CLRF PORTE
CLRF TRISA
CLRF TRISB
CLRF TRISC
CLRF TRISD
CLRF TRISE

GOTO START
;********** Podprogramy Zdrzania @20Mhz *******************
Zdrz8s CALL Zdrz4s ; this is the delay part, by how
GOTO Zdrz4s ; much is the delay ?is it the
; same a the delay just below?
Zdrz4s CALL Zdrz2s
GOTO Zdrz2s

Zdrz2s CALL Zdrz1s
GOTO Zdrz1s

Zdrz1s CALL Zdrz500m
GOTO Zdrz500m

Zdrz500m NOP
MOVLW D'121'
MOVWF ZDRZ0 ; i think Zdrz500m delays by
MOVLW D'171' ; 500ms, but how is it here?
MOVWF ZDRZ1 ;121+171+13?
MOVLW D'13'
MOVWF ZDRZ2
GOTO Zdrz


Zdrz100m NOP ; why do we use a nop ?? to delay ??
NOP ; but i thought delay is done already ?
MOVLW D'122'
MOVWF ZDRZ0
MOVLW D'137'
MOVWF ZDRZ1
MOVLW D'3'
MOVWF ZDRZ2
GOTO Zdrz

Zdrz15m CALL Zdrz5m
CALL Zdrz5m
GOTO Zdrz5m

Zdrz5m CALL Zdrz1m
CALL Zdrz1m
CALL Zdrz1m
CALL Zdrz1m
GOTO Zdrz1m

Zdrz2m CALL Zdrz1m
GOTO Zdrz1m

Zdrz1m MOVLW D'140'
MOVWF ZDRZ0
MOVLW D'7'
MOVWF ZDRZ1
MOVLW D'1'
MOVWF ZDRZ2
NOP
NOP
GOTO Zdrz

Zdrz100 CALL Zdrz40
CALL Zdrz40
CALL Zdrz10
GOTO Zdrz10

Zdrz40 CALL Zdrz10
CALL Zdrz10
CALL Zdrz10
GOTO Zdrz10

Zdrz10 MOVLW D'10'
MOVWF ZDRZ0
MOVLW D'1'
MOVWF ZDRZ1
MOVLW D'1'
MOVWF ZDRZ2
NOP
NOP
GOTO Zdrz

Zdrz DECFSZ ZDRZ0,F
GOTO Zdrz
DECFSZ ZDRZ1,F
GOTO Zdrz
DECFSZ ZDRZ2,F
GOTO Zdrz
Return

;********** Hlavny Program *******************************
Start SETF PORTA
SETF PORTB
SETF PORTC
SETF PORTD
SETF PORTE
CALL Zdrz1s
CLRF PORTA ; this part turns off the LED?
CLRF PORTB
CLRF PORTC
CLRF PORTD
CLRF PORTE
CALL Zdrz1s

GOTO Start
end



hi guys, i think i more or less understand the whole program , just that
i'm a little confuse with the delay part, and for the one in bold that i commented , could u help me check if it's correct??
 
You'll need an interface between joystick and IR transmitter. You either build one or buy a cheap universal remote, use the internal components and wire the joystick switches to replace the original keys. You connect the receiver to one port pin of the PIC and using software to decode what command is being sent from the transmitter.

any circuit diagrams or guide on how to do that ?? wat is a universal remote?
i dun understand how to do it.. thanx

is there any particular name for every IR module ?
wat does"Serial port controlled infrared transmitter with PIC" means?
is it the one i need to use ?? to control the direction of the wheelchair?? i am going to get the components soon, but i dont know how to buy it ? which one to choose ,
i just repeat wat i need IR for ..
i need to control the direction of the wheelchair manually ( with a sony joystick i guess, ) so the joystick tranmits the signal to the PIC to drive the motors ... so wat kind of IR module do i need??? is there any guide on how to connect all these parts? thanx alot
 
Jay .... i tried to use the Tiny bootloader ... but it can't seem to work it shows this
 

Attachments

  • tiny.jpg
    281.3 KB · Views: 698
hi guys,

i just need some advice, i'm rushing to finish my current project and i'm really confuse, i don't know whether to learn c language or assembly, i need to submit my project in 3 weeks but i dont think i have time to learn either of them .. i tried to learn assembly but i think think it would really take quite some time to understand the whole thing... my C is a little ok ... well , at least it looks simpler and i could understand program i see quite fast, so i need some advice from u Pros to help me decide ... is there any tutorials about programming in C ?? i really need it urgently..
 
kupikupi said:
Jay .... i tried to use the Tiny bootloader ... but it can't seem to work it shows this
Did you program that PIC with bootloader HEX before with normal programmer? It won't work without it.
 
Jay.slovak said:
Did you program that PIC with bootloader HEX before with normal programmer? It won't work without it.

yes... i did .. i changed this
Code:
LIST      P=18F4320	; change also: Configure->SelectDevice from Mplab 
xtal EQU 20000000		; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
baud EQU 115200			; standard TinyBld baud rates: 115200 or 19200

to

Code:
LIST      P=18F452	; change also: Configure->SelectDevice from Mplab 
xtal EQU 20000000		; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
baud EQU 19200			; standard TinyBld baud rates: 115200 or 19200

it's correct rite??

but i think there might be a problem with the mplab in the lab.. i think i'll convert it to hex at home then try again ...

thanx Jay ...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top