Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,165 members, 7,811,374 topics. Date: Sunday, 28 April 2024 at 10:31 AM

Microcontrollers - Programming (6) - Nairaland

Nairaland Forum / Science/Technology / Programming / Microcontrollers (34275 Views)

Help Needed On My Project Work Using Microcontrollers / How To Write Assembly Language For Microcontrollers (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply) (Go Down)

Re: Microcontrollers by Nobody: 8:09am On Jun 21, 2013
Thanks Princejude, I will try to type d full asm code.
Im trying to learn d asm language bcause it seems to b d fundamental for microcontrollers, others(C, BASIC) are just derivatives, so knowing asm really makes u understand the working principles of microcontrollers and besides, the datasheets of PICs are written exclusively with asm! Im also trying to learn C ( CCS C).
Re: Microcontrollers by Nobody: 8:26am On Jun 21, 2013
here is the full code:

list P = 16F84
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT1 equ 08h
COUNT2 equ 09h

bsf STATUS, 5
movlw 00h
movwf TRISA
bcf STATUS, 5

Start movlw 02h
movwf PORTA

Loop1 decfsz COUNT1, 1
goto Loop1
decfsz COUNT2, 1
goto Loop1

movlw 00h
movwf PORTA

Loop2 decfsz COUNT1, 1
goto Loop2
decfsz COUNT2, 1
goto Loop2

goto Start

end
Re: Microcontrollers by princejude(m): 9:30am On Jun 21, 2013
I added the "org 00" line to your code and it compiled successfully. Note the org statement is used to initialize the code. Always include it in all your asm code.


list P = 16F84
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT1 equ 08h
COUNT2 equ 09h

org 00 ; sets the origin, the program starts running here.///// Very important ////

bsf STATUS, 5
movlw 00h
movwf TRISA
bcf STATUS, 5

Start movlw 02h
movwf PORTA

Loop1 decfsz COUNT1, 1
goto Loop1
decfsz COUNT2, 1
goto Loop1

movlw 00h
movwf PORTA

Loop2 decfsz COUNT1, 1
goto Loop2
decfsz COUNT2, 1
goto Loop2

goto Start

end
Re: Microcontrollers by Nobody: 10:01am On Jun 21, 2013
Thanks Princejude, I did add "org 0" to the code myself.
The program actually build succesfully, I even run its simulation without problem, but there is a single warning by MPLAB dat TRISA is not in Bank0! maybe I shuld just ignore d warning.
Re: Microcontrollers by hopefullman: 11:20am On Jun 21, 2013
cogitoErgo: Thanks Princejude, I did add "org 0" to the code myself.
The program actually build succesfully, I even run its simulation without problem, but there is a single warning by MPLAB dat TRISA is not in Bank0! maybe I shuld just ignore d warning.
just ignore the warning.it wil work.u can even disable the warning in the mapasm setings.
Re: Microcontrollers by Nobody: 11:56am On Jun 21, 2013
hopefullman:
just ignore the warning.it wil work.u can even disable the warning in the mapasm setings.
Thanks
Re: Microcontrollers by princejude(m): 11:11am On Jun 22, 2013
LESSON 7: Serial Communication

Serial data connections are useful because only one or two signal wires are needed, compared with at least eight data lines for a parallel bus plus control signals. The typical PIC microcontroller offers a choice of serial interfaces. The best one for any given communication channel depends on the distance between nodes, the speed, and the number of hardware connections required.

Types of Serial Communication

USART
SPI
12C

USART

The universal synchronous/asynchronous receive transmit (USART) device is typically used in asynchronous mode to implement off-board, one-to-one connections. The term asynchronous means no separate clock signal is needed to time the data reception, so only a data send, data receive, and ground wires are needed. It is quick and simple to implement if a limited data bandwidth is acceptable.

A common application is connecting the PIC chip to a host PC for uploading data acquired by the MCU subsystem. The USART link can send data up to 100 meters by converting the signal to higher-voltage levels (typically 12V). The digital signal is inverted and shifted to become bipolar (symmetrical about 0V, line negative when inactive) for transmission.

The PIC 16F887 has a dedicated hardware RS232 port, but CCS C allows any pin to be set up as an RS232 port, providing functions to generate the signals in software. The basic form of the signal has 8 data bits and a stop and start bit. The bit period is set by the baud rate. A typical value is 9600 baud, which is about 10k bits per second. The bit period is then about 100μs, about 1 byte per millisecond, or 1K byte per second.

The data are transferred between shift registers operating at the same bit rate; the receiver has to be initialized to the same baud setting as the transmitter. Assuming we are looking at TTL level data, in the idle state, the line is high. When it goes low, the receiver clock is started, the data are sampled in the middle of each following data bit period, and data are shifted into the receive register



USART Operation
Re: Microcontrollers by princejude(m): 11:15am On Jun 22, 2013
SPI

The serial peripheral interface (SPI) bus provides high-speed synchronous data exchange over relatively short distances (typically within a set of connected boards), using
a master/slave system with hardware slave selection. One processor must act as a master, generating the clock. Others act as slaves, using the master clock for timing the data send and receive. The slaves can be other microcontrollers or peripherals with an SPI interface. The SPI signals are

Serial Clock (SCK)

Serial Data In (SDI)

Serial Data Out (SDO)

Slave Select (!SS)


To transfer data, the master selects a slave device to talk to, by taking its SS line low. Eight data bits are then clocked in or out of the slave SPI shift register to or from the master. No start and stop bits are necessary, and it is much faster than RS232. The clock signal runs at the same speed as the master instruction clock, that is, 5MHz when the chip is running at the maximum 20 MHz (16 series MCUs).



SPI Connection
Re: Microcontrollers by princejude(m): 11:20am On Jun 22, 2013
I2C

The inter-integrated circuit (I2C) bus is designed for short-range communication between chips in the same system using a software addressing system. It requires only two signal wires and operates like a simplified local area network.
The I2C slave chips are attached to a two-wire bus, which is pulled up to logic 1 when idle. Passive slave devices have their register or location addresses determined by a combination of external input address code pins and fixed internal decoding. If several memory devices are connected to the bus, they can be mapped into a continuous address space. The master sends data in 8-bit blocks, with a synchronous clock pulse alongside each bit. As for SPI, the clock is derived from the instruction clock, up to 5 MHz at the maximum clock rate of 20 MHz.

To send a data byte, the master first sends a control code to set up the transfer, then the
8-bit or 10-bit address code, and finally the data. Each byte has a start and acknowledge bit, and each byte must be acknowledged before the next is sent, to improve reliability.



I2C Connection
Re: Microcontrollers by hopefullman: 11:13pm On Jun 22, 2013
Thanks.what of the usb comunication.is it different to that of rs232
Re: Microcontrollers by princejude(m): 7:28am On Jun 23, 2013
hopefullman: Thanks.what of the usb comunication.is it different to that of rs232

USB communication is diferent from serial or rs232 comminication.
Right now we are on serial not usb. Usb may come later.
Re: Microcontrollers by princejude(m): 5:54pm On Jun 23, 2013
RS232 to TTL conversion circuit

Re: Microcontrollers by princejude(m): 6:44pm On Jun 23, 2013
If you are doing any serial communication stuff, ensure that you have any of the serial comm software (such as hyperTerminal, tera term or CCS's built-in siow). In this project I will used CCS's SIOW.

To open siow, browse to the CCS installation folder: C/Program file/PICC/siow. Right-click siow and Pin to Taskbar. Then click from taskbar to open it.
Re: Microcontrollers by princejude(m): 7:40am On Jun 24, 2013
[center]Setting up of SIOW (Serial Input/Output (Monitor) Window)[/center]

1. Connect your PIC16F887 chip to the serial com port of PC. If you don't have serial com port on your PC, you can use any good USB to Serial converter. Install the USB to Serial driver.

2. Open your device manager, expand Ports(COM & LPT) to view your USB to serial port connection. It was connected to COM8



3. Open siow.exe from your taskbar. Then click ok to open the next window



4. Set the baud rate to 9600 click ok to open next window.

Re: Microcontrollers by Nobody: 2:33pm On Jun 24, 2013
princejude: If you are doing any serial communication stuff, ensure that you have any of the serial comm software (such as hyperTerminal, tera term or CCS's built-in siow). In this project I will used CCS's SIOW.

To open siow, browse to the CCS installation folder: C/Program file/PICC/siow. Right-click siow and Pin to Taskbar. Then click from taskbar to open it.



























Thanks Princejude.
Re: Microcontrollers by pjude: 10:13pm On Jun 24, 2013
Chei this people has banned me (princejude) in this thread.
Re: Microcontrollers by princejude(m): 2:02pm On Jun 25, 2013
pjude: This people has banned me (princejude) in this thread.
Re: Microcontrollers by Nobody: 6:01am On Jun 26, 2013
princejude: pjude: This people has banned me
(princejude) in this thread.
Lord of heaven! no wonder I saw a hidden post and I was wondering why. Do these people really know how important this thread is to the development of this country? Every single piece of post so far on this thread have been of immense help to me and I know to many others here.
Please, whoever the moderator is, should please leave Princejude alone for us!
Re: Microcontrollers by princejude(m): 9:52am On Jun 26, 2013
unbanned, username re-activated.
Re: Microcontrollers by hopefullman: 11:56am On Jun 26, 2013
Thank God.username reactivated.pls moderator leav our thread alone o.our thread is mor important to us than threads in romance,politics section where insult is the order of the day.our thread kuku no dey reach frontpage despit its great importanc.make una let slepin dogs lye.thank u
Re: Microcontrollers by Nobody: 2:32pm On Jun 26, 2013
princejude: unbanned, username re-activated.
Thank God ooo! continue the good job my brother.
The moderators here must know that there is no way you will be on this thread without wanting to buy one thing or the other, so if you see somebody who will direct you to the right place, is that not a good thing? Before, I used to order my components from Sparkfun(in USA), but now, through this thread, I can now buy my components from Kaduna here in Nigeria. So please moderators mind who you ban oo!
Re: Microcontrollers by princejude(m): 8:03pm On Jun 26, 2013
Ok let's continue...

If you are using laptop(without serial port), buy a usb-to-serial converter from any computer accessory shop near you. The converter always has a CD which contains its driver. Install the driver and open your "Device manager" to check its COM port.

Insert the usb-to-serial converter into your usb port.



Click ok to open the next window
Re: Microcontrollers by princejude(m): 8:24pm On Jun 26, 2013


Select your Com Port (same as shown in device manager)

Set your baudrate to 9600

Click ok
Re: Microcontrollers by pjude: 8:42pm On Jun 26, 2013
Same thing happen again, it seems like this site don't like pictures. I may switch to my site...



Select your com port (same as in your device manager) and also set the baudrate to 9600

Click ok
Re: Microcontrollers by usisky(m): 8:44pm On Jun 26, 2013
PEACE ALL.

Nice thread guys....keep it up.
and mr jude, thumbs up for ur invaluable contributions. Be sure that a lot o' folks out there are getting help thru ur contributions.

@ Jude. i wanna know: what fascinating projects have u designed thus far as an electronics expert or enthusiast? PEACE!
Re: Microcontrollers by usisky(m): 8:47pm On Jun 26, 2013
PS: what's with the hidden posts? Hope the MOD ain't hating?
Re: Microcontrollers by Nobody: 8:55pm On Jun 26, 2013
usisky: PS: what's with the hidden posts? Hope the MOD ain't hating?
I just hope its not princejude and other relevant people's post they are hiding!

1 Like

Re: Microcontrollers by hopefullman: 9:56pm On Jun 26, 2013
Me sef i tire o
Re: Microcontrollers by Javanian: 11:53am On Jun 27, 2013
@Princejude and all no moderator is hiding your post or banning you. you were wrongly banned by the anti spam bot. i would try and monitor the thread to ensure it doesn't happen again.

Regards.
Re: Microcontrollers by Nobody: 3:09pm On Jun 27, 2013
Javanian: @Princejude and all no moderator is hiding your post or banning you. you were wrongly banned by the anti spam bot. i would try and monitor the thread to ensure it doesn't happen again.

Regards.
OK o, able moderator Javanian, we don dey vex well well for this thread o! Thank you very much for this your response on this thread, I must say I am happy!
Re: Microcontrollers by princejude(m): 7:03pm On Jun 27, 2013
@Javanian
Thanks for your quick reply
Re: Microcontrollers by princejude(m): 7:26pm On Jun 27, 2013
Ok back to the class:

After you have select your Com Port and baudrate then click ok to open the next window.

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply)

What Is Computer Programming / First Thing First, Learn To Program! / How To Make A Simple Calculator In Notepad Using .bat Format

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 39
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.