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.

PICC question

Status
Not open for further replies.

ptewright

New Member
If I have a few inputs from let's say PortA, and I want to concatenate those bits into an 8-bit variable(string or integer) of some sort, how can I do that??? I'm programming in C, but if you know how to do it in asm, that would be fine too... thanks
 
ptewright said:
If I have a few inputs from let's say PortA, and I want to concatenate those bits into an 8-bit variable(string or integer) of some sort, how can I do that??? I'm programming in C, but if you know how to do it in asm, that would be fine too... thanks
I'm not sure on this but i dont think that pics have strings.
but if you wanted to you could shift the bits into the varible , that i AM sure of.
 
ptewright said:
If I have a few inputs from let's say PortA, and I want to concatenate those bits into an 8-bit variable(string or integer) of some sort, how can I do that??? I'm programming in C, but if you know how to do it in asm, that would be fine too... thanks

What do you mean by 'concatenate'?.

In assembler you can simply read the port and then write it back to a variable - like this:

Code:
movf PortA, w
movwf Variable
 
ptewright said:
If I have a few inputs from let's say PortA, and I want to concatenate those bits into an 8-bit variable(string or integer) of some sort, how can I do that??? I'm programming in C, but if you know how to do it in asm, that would be fine too... thanks

PICC (are you talking HiTech or CCS?) will allow you to look at a port as either individual bits or all 8 as a byte. You can make a string of bytes (chars), but I have no idea what you're talking about in this context. In response to "can it be done?", doesn't sound like you're asking for anything outside the easiest, most basic ops, so yes it's possible. But what do you want to do?
 
what i want to do is.......

sorry if you misunderstood me
basically, if i have the following inputs at porta:
ra1=0, ra2=1, ra3=0, ra4=1, i would like to combine them into "0110" and assign that to a variable or an 8 bit integer. Is that possible?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top