WRITE_REGISTER_BUFFER_UCHAR...

From: mozart (helgheim_at_stud.ntnu.no)
Date: 03/29/04


Date: Mon, 29 Mar 2004 18:55:39 +0200


Hey

I have a problem writting to my device, (possible also reading, not sure..):

In my DispatchControl routine i do the following:
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////

1. PSAM_REGISTERS samReg = pdx->membase;
// PSAM_REGISTERS is a pointer to a structure containing the structure of my
device's common register.
// samReg->Ctrl (belowe) is therefore an array of two bytes.
....
....
2. WRITE_REGISTER_BUFFER_UCHAR(samReg->Ctrl, temparray1, 2);
3. READ_REGISTER_BUFFER_UCHAR(samReg->Ctrl, temparray2, 2);

////////////////////////////////////////////////////////////////////////////
///////////////////////////////////

typedef struct _SAM_REGISTERS {

// Register offset R/W Description
// (in bytes)
//--------------------------------------------------------------------------
---------
    UCHAR Ctrl[2]; // 2 bytes //w SAM Control Register
    UCHAR Status[2]; // 2 bytes //r Status field
    UCHAR TxBuff [TXBUFF_SIZE]; // 512 bytes //w TxBuffer
    UCHAR RxBuff [RXBUFF_SIZE]; // 506 bytes //r RxBuffer
 UCHAR IntClear; // 1 byte //r Read to clear int from SAM
 UCHAR IntSet; // 1 byte //w Write to set int to SAM
//--------------------------------------------------------------------------
----------

} SAM_REGISTERS, *PSAM_REGISTERS;

////////////////////////////////////////////////////////////////////////////
///////////////////////////////////

I use the Locals window in WinDbg to see what happens, and I se that after I
initialize samReg in line one above I get a structure where every entery is
0xff.(pdx->membase is stored as a PSAM_REGISTER!) When I use W_R_B_UCHAR
nothing happens. But when I read with R_R_B_UCHAR i get 0xff as in the
return value. I suspect that 0xff is not the right value, the value that is
in this register in the device, but why am I able of reading the structures
bogus (false) values with the R_R_B_UCHAR routine? And not write to is?

And what do you think that I'm doing wrong. When I get membase, in
StartDevice, I see that this is the memory resource adresse that is visable
in the resource tab of the Device Manger entery. But does this resource
address map up agains the PcCardConfig memory adresse that I indicated in
the inf file? Because that is the address I want to read and write.

Thanks
sorry for this "bad" question.



Relevant Pages