Jump to content

SamuelVergeiner

Members
  • Content Count

    4
  • Joined

  • Last visited

About SamuelVergeiner

  • Rank
    Noob Class
  1. The line concerning watchdog was copied from a program we wrote with our teacher, haha. I bet, he doesn't even know how to code himself *face palm*. But, i googled it and the posts there say that the line "WDTCTL = WDTPW + WDTHOLD;" should stop watchdog. However, others say that "WDTCL = WDTPW | WDTHOLD;" Which one is the right one? Secondly, I am reading P6.5 - in the byte P6 the "x" (00x0000). So, I have to shift it four positions to the right in order for bit0 to be the value I want to read, if I understand this correctly. I do not have my MSP with me at the moment, but I will do some trial and error today and post my "results".
  2. I have implemented your changes in my program, but it does not work after all. Thank you for pointing me to this error - I must have confused the modules in- and outputs with the controller's. I do not know what else I could try. My teacher didn't even want to look at my program. He just kept saying that the internet is my friend. My program now looks like this: #include "main.h" #include <stdint.h> void WriteCMD(unsigned int CMD); void Write1(); void Write0(); int check_status(); void main() { //WDTCTL = WDTPW + WDTHOLD; // stop watchdog timer to prevent time out reset //init ports P6DIR &= ~BIT5; //set SDO as input on P6.5 P6REN &= ~BIT5; P3DIR &= ~BIT4; //set nIRQ as input on P3.4 P3REN &= ~BIT4; P3REN |= BIT4; P3DIR |= BIT3; //set nSEL as output on P3.3 P1DIR |= BIT6; //set SCK as output on P1.6 P6DIR |= BIT6; //set SDI as output on P6.6 //init rfm12b WriteCMD(0x80D8);//enable register,433MHz,12.5pF WriteCMD(0x82D8);//enable receive,!PA WriteCMD(0xA640);// WriteCMD(0xC647);// WriteCMD(0x94A0);//VDI,FAST,134kHz,0dBm,-103dBm WriteCMD(0xC2AC); WriteCMD(0XCC77);// WriteCMD(0xCA80); WriteCMD(0xCA83);//FIFO8,SYNC, WriteCMD(0xC49B); WriteCMD(0x9850);//!mp,9810=30kHz,MAX OUT WriteCMD(0xE000);//NOT USE WriteCMD(0xC800);//NOT USE WriteCMD(0xC000);//1.0MHz,2.2V //statusregister auslesen int cnt = 16; int result = 0; int temp = 0; P3OUT &= ~BIT3; //set nSEL low P6OUT &= ~BIT6; //set SDI low while(cnt--) { result <<=1; P1OUT |= BIT6; // set SCK high __delay_cycles(10); temp = P6IN; temp >>=4; temp &= 0x01; result |= temp; P1OUT &= ~BIT6; //set SCK low __delay_cycles(10); } P3OUT |= BIT3; //set nSEL high; __no_operation(); while(1) { __no_operation(); result= result-1; result = result+1; } } void WriteCMD( unsigned int CMD ) { unsigned char n=16; P1OUT &= ~ BIT6; //set SCK low P3OUT &= ~BIT3; //set nSEL low, selecting the rfm12b __delay_cycles(10); while(n--) { if(CMD&0x8000) { Write1(); } else { Write0(); } CMD=CMD<<1; } P1OUT &= ~ BIT6; //set SCK low P3OUT |= BIT3; //set nSEL high, deselecting the rfm12b __delay_cycles(10); } void Write0 (void) { P1OUT &= ~BIT6; //set SCK low __delay_cycles(10); P6OUT &= ~BIT6; //set SDI low __delay_cycles(10); P1OUT |= BIT6; //set SCK high, rfm now reads SDO __delay_cycles(10); P1OUT &= ~BIT6; //set SCK low } void Write1(void) { P1OUT &= ~BIT6; //set SCK low __delay_cycles(10); P6OUT |= BIT6; //set SDI high __delay_cycles(10); P1OUT |= BIT6; //set SCK high, rfm now reads SDO __delay_cycles(10); P1OUT &= ~BIT6; //set SCK low } And for clearence, the pins in my initiation (SDO, SDI, nIRQ, nSEL, SCK) are connected as in the attached picture. Meaning that the SDO port of the RFM12b is connected to P6.5 and is defined as an input for my controller. Now, that the initiation is correct, only the connections can be wrong. My program is right after all, isn't it? I hope I am not getting on your nerves with my noobery, but I can't solve this problem on my own. Looking forward to your reply!
  3. Thank you for your answer. First things first, I am a student at a technical school in Austria and this is part of a project for class. My problem is that our teacher does not really want to help us if we have problems. He always tells us to "google ourself". Now, that I have struggled so long, I thought that my only way to ever getting this thing to run is by asking in a forum, and here we are. (And by the way, I have to use bitbanging because my teacher wants me to.) So, I have implemented your code, with a slight change, so I can analyse it better. Now, my result is always 0x0000. Shouldn't I be getting "0x4000"? All the connections are soldered properly and my program seems to do what it should, but I simply do not get the right value. What else can I do? My code is exactly the same except this passage: /statusregister auslesen int cnt = 16; int result = 0; int temp = 0; P3OUT &= ~BIT3; //set nSEL low P6OUT &= ~BIT5; //set SDO low while(cnt--) { result <<=1; temp = P6IN; temp >>=6; temp &= 0x01; result |= temp; P1OUT |= BIT6; // set SCK high __delay_cycles(10); P1OUT &= ~BIT6; //set SCK low __delay_cycles(10); } P3OUT |= BIT3; //set nSEL high; __no_operation(); while(1) { __no_operation(); result= result-1; result = result+1; } } Please help me, I am beginning to loose my mind on this...
  4. Hello, I hope this is the right forum to post in, I'm a new user here... So, I have been trying to get the RFM12b module to work with my MSP430F5529. The connections are as follows for transmission: VDD --> 3.3V GND--> GND SDO-->P6.5 nIRQ-->P3.4 nSEL-->P3.3 SCK-->P1.6 SDI-->P6.6 Now, I have the following code, in which I only configure the module and try to read its status register: #include "main.h" void WriteCMD(unsigned int CMD); void Write1(); void Write0(); int check_status(); void main() { //init ports P6DIR |= BIT5; //set SDO as output on P6.5 P3DIR &= ~BIT4; //set nIRQ as input on P3.4 P3REN |= BIT4; P3DIR |= BIT3; //set nSEL as output on P3.3 P1DIR |= BIT6; //set SCK as output on P1.6 P6DIR &= ~BIT6; //set SDI as input on P6.6 P6REN &= ~BIT6; //init rfm12b WriteCMD(0x80D8);//enable register,433MHz,12.5pF WriteCMD(0x82D8);//enable receive,!PA WriteCMD(0xA640);// WriteCMD(0xC647);// WriteCMD(0x94A0);//VDI,FAST,134kHz,0dBm,-103dBm WriteCMD(0xC2AC); WriteCMD(0XCC77);// WriteCMD(0xCA80); WriteCMD(0xCA83);//FIFO8,SYNC, WriteCMD(0xC49B); WriteCMD(0x9850);//!mp,9810=30kHz,MAX OUT WriteCMD(0xE000);//NOT USE WriteCMD(0xC800);//NOT USE WriteCMD(0xC000);//1.0MHz,2.2V //statusregister auslesen int cnt = 16; int result = 0; int temp = 0; P3OUT &= ~BIT3; //set nSEL low P6OUT &= ~BIT5; //set SDO low while(cnt--) { __delay_cycles(10); temp = P6IN; temp = temp <<2; result |= temp; result = result <<1; P1OUT |= BIT6; // set SCK high __delay_cycles(10); __no_operation(); P1OUT &= ~BIT6; //set SCK low __delay_cycles(10); P3OUT |= BIT3; //set nSEL high; } __no_operation(); while(1) { __no_operation(); result= result-1; result = result+1; } } void WriteCMD( unsigned int CMD ) { unsigned char n=16; P1OUT &= ~ BIT6; //set SCK low P3OUT &= ~BIT3; //set nSEL low, selecting the rfm12b __delay_cycles(10); while(n--) { if(CMD&0x8000) { Write1(); } else { Write0(); } CMD=CMD<<1; } P1OUT &= ~ BIT6; //set SCK low P3OUT |= BIT3; //set nSEL high, deselecting the rfm12b __delay_cycles(10); } void Write0 (void) { P1OUT &= ~BIT6; //set SCK low __delay_cycles(10); P6OUT &= ~BIT5; //set SDO low __delay_cycles(10); P1OUT |= BIT6; //set SCK high, rfm now reads SDO __delay_cycles(10); P1OUT &= ~BIT6; //set SCK low } void Write1(void) { P1OUT &= ~BIT6; //set SCK low __delay_cycles(10); P6OUT |= BIT5; //set SDO high __delay_cycles(10); P1OUT |= BIT6; //set SCK high, rfm now reads SDO __delay_cycles(10); P1OUT &= ~BIT6; //set SCK low } Now, the status register should read "0x4000", but I always get "0xFFF8" and this makes me nervous. I have also tried simply connecting two modules and sending data between the two with a bit different programms, but that also didn't yield any results. Can anyone here help me? I've been to the 10th site of Google search results and haven't found anything that could help me. I got my instructions from the following site: https://gobotronics.wordpress.com/2010/10/07/rfm12-programming/. Thanks in advance!
×
×
  • Create New...