Go to Post A Strong FRC Team Should... have a clear vision and an understanding of how to achieve it within their means. - jwfoss [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-10-2007, 22:06
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
PIC bsf instruction

After spending the last 3 hours trying to figure out what's going on, I think I need to verify my conclusion because it seems strange to me.

If I set the output of more than one pin, they like to turn on and off. I've narrowed down the problem to the way I'm setting my outputs. I'm using a single port and setting individual pins using bsf and bcf. However, it seems that bsf will set ONLY that one bit; all others will be cleared. This doesn't sound right to me.

I scoped the outputs and it seems like that is exactly what it's doing. The first pin I set only stays high for one instruction cycle. When the next pin turn on, the first one turns off. Then, they swap when the first pin gets set high again.

I've attached my code and the scope capture. Ch1 is pin C0 and Ch2 is pin C2.
Attached Thumbnails
Click image for larger version

Name:	tek0001.jpg
Views:	85
Size:	85.6 KB
ID:	5738  
Attached Files
File Type: txt range.asm.txt (1.2 KB, 83 views)
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------
  #2   Spotlight this post!  
Unread 06-10-2007, 23:29
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,562
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: PIC bsf instruction

I'm far from an expert on the PIC, but looking over the data sheet and instruction set, it seems that bsf and bcf should be working like you'd think. I don't know how MPASM handles things, but perhaps you don't have the right bank selected or something. Also, and this is a complete guess, but there might be some issue with stale data or a delayed write back or something with those happening back to back, so perhaps tossing some NOPs in front, in between, and behind all your loop instructions there and see if that fixes things.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #3   Spotlight this post!  
Unread 07-10-2007, 14:33
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
Re: PIC bsf instruction

I figured it out.

By default, pins that can be used as analog channels are set to analog. If you want to use them as digital, you have to set them using the ANSEL and ANSELH registers. This needs to be done in addition to setting them as outputs or inputs.
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------
  #4   Spotlight this post!  
Unread 07-10-2007, 17:42
3dude_2231's Avatar
3dude_2231 3dude_2231 is offline
no one messes with a Thingy =|
AKA: Menscher,Ran Menscher =]
FRC #2231 (Onyxtronix)
Team Role: Leadership
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Shoham, Israel
Posts: 233
3dude_2231 is a jewel in the rough3dude_2231 is a jewel in the rough3dude_2231 is a jewel in the rough
Send a message via MSN to 3dude_2231
Re: PIC bsf instruction

right,
too bad I only saw your post now,
I assume you have the PICKIT2, right? ^^
give me a call anytime if you have any questions.
(I'm online on my MSN most of the time).
__________________
Redefining the word "Rookie". (for 2 years now..)


Israeli Off Season Games: WINNERS!
check out this cool project I'm into..

  #5   Spotlight this post!  
Unread 07-10-2007, 20:01
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 357
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Re: PIC bsf instruction

One other note: bsf and bcf are read-modify-write instructions. The pins of the port are read, the pin you specify in the instruction is modified, and then all the pins are written out. If a pin is allowed to drive it to what you set (a legal high or low), its fine. If the pin was driving a load which kept it from going to a high enough voltage to be a high level, it would be written back to a low.

The Pic18 series parts have output latch registeres, so this is not a probem with them. For the 10, 12, and 16 series parts, you need to be aware of it.

Brian
__________________
Brian K
Team 1225 Robotics Mentor
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vex transmitter Instruction Manual Needed (FOUND IT!) boyntonstu VEX 0 04-08-2007 08:00


All times are GMT -5. The time now is 14:55.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi