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 support@ccsinfo.com

SPI problem with max6950

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



Joined: 23 Dec 2005
Posts: 23

View user's profile Send private message

SPI problem with max6950
PostPosted: Fri Jul 20, 2007 4:26 am     Reply with quote

Hello folks,I am driving 5 7-seg displays with max6950 and 16f689 as the master mcu.I use the built in H/W SPI to transfer data.The wierd thing is ,when i try to setup the SPI using CCS library functions,i get the following condition
Code:


#define SPI_MODE_0_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)

.................... ////////////////////////////////////////////////
.................... ////*Internal Peripherals Enable/Disable*/////
.................... ////////////////////////////////////////////
.................... 
.................... void Internal_Peripherals_init(void)
.................... {
.................... setup_spi(SPI_MASTER|SPI_MODE_0_0|SPI_CLK_DIV_4);
*
030E:  BCF    14.5
030F:  BSF    03.5
0310:  BCF    07.7
0311:  BSF    06.4
0312:  BCF    06.6
0313:  MOVLW  20
0314:  BCF    03.5
0315:  MOVWF  14
0316:  MOVLW  40
0317:  BSF    03.5
[color=red]0318:  MOVWF  14[/color]
.................... //disable_interrupts(INT_SSP);
.................... //SET_TRIS_B(0x20);   //   |0|0|1|0|-|-|-|-|   see pin_assignments.txt
.................... //TrisB could be reset by setup_spi.We dont read SPI so TRIS adjusted .
.................... 
.................... //comparator disabled below,not needed



Also when i try to write SPI data to port,i get the following:
Code:

.................... void my_spi_write(int8 reg_address,int8 reg_value)
.................... {
.................... int8 count,buf[2];
.................... 
.................... buf[0]=reg_address;
*
02E4:  MOVF   55,W
02E5:  MOVWF  58
.................... buf[1]=reg_value;
02E6:  MOVF   56,W
02E7:  MOVWF  59
.................... 
.................... for(count=0;count<2;count++)
02E8:  CLRF   57
02E9:  MOVF   57,W
02EA:  SUBLW  01
02EB:  BTFSS  03.0
02EC:  GOTO   2F7
.................... {
.................... spi_write(reg_address);
02ED:  MOVF   55,W
02EE:  MOVWF  13
02EF:  BSF    03.5
[color=red]02F0:  BTFSC  14.0[/color]
02F1:  GOTO   2F4
02F2:  BCF    03.5
02F3:  GOTO   2EF
.................... }
02F4:  BCF    03.5
02F5:  INCF   57,F
02F6:  GOTO   2E9
.................... 
.................... }
02F7:  RETLW  00


Shouldnt that be 94h instead of 14h in both setup and write modules?

Just for the record,my PCM ver. is 3.237
Ttelmah
Guest







PostPosted: Fri Jul 20, 2007 6:30 am     Reply with quote

No.
There is actually no such possible instruction as 'MOVWF 0x94'. If you look at the instruction description, only _seven bits_ are allowed for the direct address on this instruction.
What does BSF 03.5 do?....
Basically it provides the 'extra' bit - actually sets one bit of two extra, which are added as the high bits to the instruction.

Best Wishes
codewrecker2



Joined: 23 Dec 2005
Posts: 23

View user's profile Send private message

PostPosted: Fri Jul 20, 2007 12:17 pm     Reply with quote

Many thanx on that quick reply .I thot "BSF 03.5" was just a bank switch command to access the SFR(or is it?).feels good to know i was wrong.gets my feet back on ground .

Ok,the reason i went to the listing was because the spi_write was looping forever in mplab sim (SSPBUF wasnt clearing o something like that)

Now i read that mplab(mine is ver7.21) sim dont support spi simulation.does that answer my problem.can i be certain it would work in the real world?

Many thanx.
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