CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with #byte - memory mapped port won't work

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dima2882



Joined: 13 Jul 2005
Posts: 25
Location: Maryland

View user's profile Send private message

Problem with #byte - memory mapped port won't work
PostPosted: Wed Sep 14, 2005 9:21 am     Reply with quote

Hi all,
I am trying to read, with a small amount of code, the value of all 8 inputs to Port A of the PIC16F88. I am then trying to save that value, and send it over the serial port. I tested the SPI link, and had the PIC send sample data over it, which worked. But the #byte stuff does not... Here's the code I used:

Code:

// Configure chip and compiler
#include "16F88.h"
#fuses INTRC_IO,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOMCLR
#use delay(clock=4000000)
#zero_ram
#byte PORTA = 5

#define   F88_CS      PIN_B5

void main(void)
{
   // Variables
   int data;

   // Configure pin direction
   #use fast_io(A)
   #use fast_io(B)
   set_tris_a(0b11111111);
   set_tris_b(0b00111010);

   // Setup the SPI port
   setup_spi(SPI_SLAVE | SPI_H_TO_L | SPI_CLK_DIV_4);

   while(1)
   {
      if(input(F88_CS) == 0)
      {
         data = PORTA;
         spi_write(data);
      }   
      else
      {
         delay_cycles(1);
      }

   }
   return;
}
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 14, 2005 9:59 am     Reply with quote

Are you sure its #byte problem? try
data = input_a();
and comment out use fast IO and #byte on port A
AND BTW
I wouldn't use fastIO on port B when the spi is on port B.
Let the compiler handle it.
dima2882



Joined: 13 Jul 2005
Posts: 25
Location: Maryland

View user's profile Send private message

PostPosted: Wed Sep 14, 2005 12:20 pm     Reply with quote

Aah. I didn't know the compiler had a built-in input_a() function. That renders the #byte low-level stuff unecessary. Thanks for your help.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 14, 2005 3:04 pm     Reply with quote

Keep in mind
Fast IO will save a few instructions.
Read up on exactly what it does.
I only use it when I think it will give me an advantage.
Like in a driver that can be maped to different ports with 1 line.
Code:
struct lcd_pin_map
{
  int8    data;//data bus
  BOOLEAN rs; //command/data_bar  sometimes refered to as rs..register select
  BOOLEAN rw; //read/write_bar
  BOOLEAN enable;//chip enable
} lcd;

#BYTE lcd = 8 // This puts the entire structure on D and E
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group