Quick Search for:  in language:    
PIC,matrices,with
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 728,035. lines
 Jobs: 113. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for C/ C++
OneInstance problem fix
By Salah_GIS on 2/18


Bar Chart
By Cris Friolo on 2/18


Pacman
By Deddi Hariprawira on 2/18


Click here to see a screenshot of this code!TExt STatistical generatOR (TESTOR)
By bagsta on 2/17

(Screen Shot)

Medical Store Inventory
By Prathamesh on 2/17


Click here to see a screenshot of this code!Num_Magic
By Arindam Ray on 2/17

(Screen Shot)

Space Attack
By Daniel Bjorndahl on 2/16


Spy Ferret Spyware Cracker
By Jerome Scott II on 2/16


Click here to see a screenshot of this code!Hearts
By Arindam Ray on 2/16

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Matrices with PIC Microcontroller

Print
Email
 
VB icon
Submitted on: 1/13/2004 6:32:05 PM
By: Rockwell  
Level: Advanced
User Rating: Unrated
Compatibility:C

Users have accessed this code 238 times.
 
(About the author)
 
     How to do matrices with the PIC microcontroller
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: Matrices with PIC Microcontroll
//     er
// Description:How to do matrices with t
//     he PIC microcontroller
// By: Rockwell
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/vb/scripts/Sh
//     owCode.asp?txtCodeId=7424&lngWId;=3//for details.//**************************************
//     

		list p=18f452
		include <p18f452.inc>
cntr	equ 0x00;		locations 0x00 to 0x05 in data memory	assigned to the following
cntc	equ		0x01;	
row		equ		0x02;
col		equ		0x03;
temp	equ		0x04;
ans		equ		0x05;
mat		db		0x00,0x01,0x02,0x03;	the table of values for the matrix
		db		0x10,0x11,0x12,0x13;
		db		0x20,0x21,0x22,0x23;
		db		0x30,0x31,0x32,0x33;
		org 0x040
		goto	start;
rows	movff	cntr,temp;
		movff	cntr,row;
		movf	cntr,w;
		addwf	temp,f;
		movf	temp,w;
		addwf	temp,w;
		addwf	TBLPTRL,f;
		return;
start	movlw	0x02;initialize counter for rows
		movwf	cntr;
		movlw	0x02;initialize counter for columns
		movwf	cntc;
		movlw	high mat;	read higher byte of the matrix to w reg
		movwf	TBLPTRH;	initialize to table pointer high
		movlw	low mat;	read lower byte of the matrix to w reg
		movwf	TBLPTRL;	initialize to table pointer low
		call	rows		;call routine for shifting rows horizontally
		movf cntc,w;		load wreg with no of the column
		movff cntc,col;
		addwfc TBLPTRL,f;	add wreg with tblptrl to point to the corresponding column.
		tblrd*;	read the contents pointed by table pointer 
		movf	TABLAT,w;and store in wreg
		movwf	ans;move result to ans reg
		clrf	TBLPTRL;clear tblptr for next iteration.
stop	goto	stop;end of the program
		end
;rows	movf	cntr,w;
;		addwf	cntr,f;
;		movf	cntr,w;
;		addwf	cntr,w;
;		addwf	TBLPTRL,f;
;		return;


Other 29 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.