Register variable

This is a discussion on Register variable within the C Programming forums, part of the General Programming Boards category; I have an problem with my code, it has to read the registers of the microcontroller and then store it ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    19

    Register variable

    I have an problem with my code, it has to read the registers of the microcontroller and then store it in ddr
    Code:
    char leesOutput( char nummer )
    {
      unsigned char ddr[4];
      char output = 0;
      /*DDR Variable with Registers*/
      switch( nummer )
      {
      case 1: // Out 1
        output = ( ddr[ 0 ] >> 0 ) & 0x01;
        break;
      case 2: // Out 2
        output = ( ddr[ 0 ] >> 1 ) & 0x01;
        break;
      case 3: // Out 3
        output = ( ddr[ 0 ] >> 2 ) & 0x01;
        break;
      case 4: // Out 4
        output = ( ddr[ 0 ] >> 3 ) & 0x01;
        break;
      case 5: // Out 5
        output = ( ddr[ 0 ] >> 4 ) & 0x01;
        break;
      case 6: // Out 6
        output = ( ddr[ 0 ] >> 5 ) & 0x01;
        break;
      case 7: // Out 7
        output = ( ddr[ 0 ] >> 6 ) & 0x01;
        break;
      case 8: // Out 8
        output = ( ddr[ 0 ] >> 7 ) & 0x01;
        break;
      case 9: // Out 9
        output = ( ddr[ 2 ] >> 7 ) & 0x01;
        break;
      case 10: // Out 10
        output = ( ddr[ 2 ] >> 6 ) & 0x01;
        break;
      case 11: // Out 11
        output = ( ddr[ 2 ] >> 5 ) & 0x01;
        break;
      case 12: // Out 12
        output = ( ddr[ 2 ] >> 4 ) & 0x01;
        break;
      }
      return output;
    }
    The place of the code is indicated with bold lettertype. I have been looking in the datasheet of the Microcontroller and I couldn't find anything. Microcontroller = Fujitsu MB90495 Family

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    Which 'registers' are you talking about?
    Being a micro controller, there's all sorts of things which might be called 'a register'.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Maybe this document will help:
    http://edevice.fujitsu.com/fj/DATASH...ds/e713713.pdf

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  2. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 12:25 PM
  3. Static global variable acting as global variable?
    By Visu in forum C Programming
    Replies: 2
    Last Post: 07-20-2004, 08:46 AM
  4. Use of variable
    By alice in forum C Programming
    Replies: 8
    Last Post: 06-05-2004, 07:32 AM
  5. Replies: 2
    Last Post: 04-12-2004, 01:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21