Tool/software: Code Composer Studio
Hi,
I am trying to develop a project for RF430FRL152H to communicate with one digital sensor over SPI for several weeks already. Since there is no any SPI example is given, I am modifying SensorHub Project which is realted with the I2C.
As far as I understand, SensorHub Project is able to read three different sensor values and this values are sent through the NFC. I just need to read one sensor and sent one value but as frequent as possible.
In SensorHub Project, DigitalSensorInit() function is called once to initialize the chip and the sensors. When I run the project on CCS, a warning is appearing : Target not run as the symbol "main" is not defined. I am ignoring this warning and trying to debug the project with onboard LED on EVM. If I put a LED blink function in this DigitalSensorInit() function, LED is blinking on the first couple of seconds of the initialization as expected. So no problem here.
But when I put same LED blink function inside the DigitalSensorMeasurement () function, nothing happens. I tried to 'tap' with NFC reader to the EVM but it also didn't help. As stated in the comment section, this function should be "Called by the RF430FRL152H ROM code." Where is the ROM code? How can I modify it or do i need to modify it?
It is also stated on the DigitalSensorMeasurement() function comment section: "Called every time there is a digital sensor measurement needed determined by the scheduler". I couldn't find any information about this scheduler. Only related content is on Firmware User's Guide (slau603b.pdf) section 3. It is not explaining anything about what is it and how we can set it. Please give me information about scheduler. And why my DigitalSensorMeasurement function is not working?
Sincerely,
Selman.
#include <rf430frl152h.h> #include "main.h" #include "types.h" #pragma RETAIN (DigitalSensorInit) #pragma CODE_SECTION (DigitalSensorInit, ".fram_driver_code") //see .cmd file for details - all new firmware must go into fram_driver_code memory section space void DigitalSensorInit() { //Set Ports to GPIO Mode P1SEL0 = 0x00; P1SEL1 = 0x00; //Set pin 1.4 to output P1DIR = 0x10; //Toggle Output High P1OUT = 0x10; _delay_cycles(1000000); //Toggle Output Low P1OUT = 0x00; _delay_cycles(1000000); P1OUT = 0x10; _delay_cycles(1000000); P1OUT = 0x00; _delay_cycles(2000000); P1OUT = 0x10; _delay_cycles(1000000); UCB0CTLW0 |= UCSWRST; // reset P1SEL0 |= 0x0F; // CLK, MOSI, SOMI, CS option select registers P1SEL1 |= 0x0F; P1DIR |= 0x0D;//D? // Enable, output direction P1OUT &= ~0x08; // Pull CS low to enable SPI UCB0CTLW0 |= UCMSB + UCMST + UCSYNC; // 3 pin, 8 bit SPI mstr, MSB first UCB0CTL1 |= UCSSEL_2; // SMCLK as clock source UCB0BR0 = 0x02; UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // init USCI state maschine by pulling the reset low, "ENABLE spi" return; } #pragma RETAIN (DigitalSensorMeasurement) #pragma CODE_SECTION (DigitalSensorMeasurement, ".fram_driver_code") //see .cmd file for details - all new firmware must go into fram_driver_code memory section space u08_t DigitalSensorMeasurement () { u08_t temp_data[2]; // used for temporary data and the 16-bit data that is sampled u08_t sensor_sampled = 0; // flag to keep track if any sensor was actually sampled P1SEL0 = 0x00; P1SEL1 = 0x00; //Set pin 1.4 to output P1DIR = 0x10; //Toggle Output High P1OUT = 0x10; _delay_cycles(1000000); //Toggle Output Low P1OUT = 0x00; _delay_cycles(1000000); P1OUT = 0x10; _delay_cycles(1000000); P1OUT = 0x00; _delay_cycles(2000000); P1OUT = 0x10; _delay_cycles(1000000); u16_t hr; //32 mi yapsak? if (SENSOR_TYPE_MAILBOX == DIGITAL_SENSOR1) // does the ROM code request digital sensor 1 (SHT21 temperature) to be sampled? { ISL29023_I2C_Read(RTOR, temp_data); hr = 60;///(((((u16_t)temp_data[1] | (((u16_t)(temp_data[0])) << 8))>>2) & 0x3fff)*0.008); RESULT_MAILBOX = (u16_t) hr; // store the result in the mailbox so that the ROM code will use it sensor_sampled = 1; // sensor sampling was performed } else if(SENSOR_TYPE_MAILBOX == DIGITAL_SENSOR2) // does the ROM code request digital sensor 2 (SHT21 humidity) to be sampled? { sensor_sampled = 0; // sensor sampling was performed } else if(SENSOR_TYPE_MAILBOX == DIGITAL_SENSOR3) // does the ROM code request digital sensor 3 (ISL29023 light) to be sampled? { sensor_sampled = 0; // sensor read was performed } return sensor_sampled; // if 1 indicates that a sensor read was performed, the ROM code will only store the value on a non-zero result here } #pragma CODE_SECTION (SHT_21_I2C_Master_Measurement, ".fram_driver_code") //see .cmd file for details - all new firmware must go into fram_driver_code memory section space void SHT_21_I2C_Master_Measurement(u08_t command, u08_t * rxData) { return; } #pragma CODE_SECTION (ISL29023_I2C_Read, ".fram_driver_code") //see .cmd file for details - all new firmware must go into fram_driver_code memory section space void ISL29023_I2C_Read(u08_t addr, u08_t * value) { UCB0CTL1 &= ~UCSWRST; // put eUSCI out of reset mode P1OUT &= ~0x08; // CS enable by pulling CSn low while(P1IN & 0x02); // Wait for ... ready, check Miso response UCB0IFG &=~ UCTXIFG; // Clear flag UCB0TXBUF = (addr<<1) | RREG; // send Address by putting in SPI buffer while(!(UCB0IFG & UCTXIFG)); // Wait for TX to finish (status byte receive) while(!(UCB0IFG & UCRXIFG)); // Wait for TX to finish (status byte receive) UCB0IFG &=~ UCRXIFG; // Clear Flag value[0] = UCB0RXBUF; // read the LSB while(!(UCB0IFG & UCRXIFG)); // Wait for TX to finish (status byte receive) UCB0IFG &=~ UCRXIFG; // Clear Flag value[1] = UCB0RXBUF; // read the MSB asdasd while(!(UCB0IFG & UCRXIFG)); // Wait for TX to finish (status byte receive) P1OUT |= 0x08; // Pull CS high to disable SPI UCB0CTL1 |= UCSWRST; // put I2C in reset mode return; } #pragma CODE_SECTION (ISL29023_I2C_Write, ".fram_driver_code") //see .cmd file for details - all new firmware must go into fram_driver_code memory section space void ISL29023_I2C_Write(u08_t addr, u08_t * value) { // UCBRX or UCBTX ??? UCB0CTL1 &= ~UCSWRST; // put eUSCI out of reset P1OUT &= ~0x08; // CS enable by pulling CSn low while(P1IN & 0x02); // Wait for ... ready, check Miso response UCB0IFG &=~ UCTXIFG; // Clear flag UCB0TXBUF = addr; // send Address by putting in SPI buffer while(!(UCB0IFG & UCTXIFG)); // Wait for TX to finish (status byte receive) UCB0IFG &=~ UCTXIFG; // Clear Flag UCB0TXBUF = value[0]; // Send data while(!(UCB0IFG & UCTXIFG)); // Wait for TX to finish (status byte receive) UCB0IFG &=~ UCTXIFG; // Clear Flag UCB0TXBUF = value[1]; // Send data while(!(UCB0IFG & UCTXIFG)); // Wait for TX to finish (status byte receive) UCB0IFG &=~ UCTXIFG; // Clear Flag UCB0TXBUF = value[2]; // Send data while(!(UCB0IFG & UCTXIFG)); // Wait for TX to finish (status byte receive) P1OUT |= 0x08; // Pull CS high to disable SPI UCB0CTL1 |= UCSWRST; // put the eUSCI into reset mode return; } // ******************************************************** // It is not recommended to change anything below this line // The ROM code needs the below ISRs to be kept as they are // ******************************************************** //#pragma CODE_SECTION(RFPMM_ISR, ".fram_driver_code") //comment this line for using ROM's RFPMM ISR, uncomment next one #pragma CODE_SECTION(RFPMM_ISR, ".rfpmm_rom_isr") //comment this line for creating a custom RFPMM ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = RFPMM_VECTOR __interrupt void RFPMM_ISR(void) { } //#pragma CODE_SECTION(PORT1_ISR, ".fram_driver_code") //comment this line for using ROM's PORT1 ISR, uncomment next one #pragma CODE_SECTION(PORT1_ISR, ".port1_rom_isr") //comment this line for creating a custom PORT1 ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = PORT1_VECTOR __interrupt void PORT1_ISR(void) { } //#pragma CODE_SECTION(SD_ADC_ISR, ".fram_driver_code") //comment this line for using ROM's SD14_ADC ISR, uncomment next one #pragma CODE_SECTION(SD_ADC_ISR, ".sd_14_rom_isr") //comment this line for creating a custom SD14_ADC ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = SD_ADC_VECTOR __interrupt void SD_ADC_ISR(void) { } //#pragma CODE_SECTION(USCI_B0_ISR, ".fram_driver_code") //comment this line for using ROM's USCI_B0 ISR, uncomment next one #pragma CODE_SECTION(USCI_B0_ISR, ".usci_b0_rom_isr") //comment this line for creating a custom USCI_B0 ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = USCI_B0_VECTOR __interrupt void USCI_B0_ISR(void) { } //#pragma CODE_SECTION(RF13M_ISR, ".fram_driver_code") //comment this line for using ROM's RF13M ISR, uncomment next one #pragma CODE_SECTION(RF13M_ISR, ".rf13m_rom_isr") //comment this line for creating a custom RF13M ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = RF13M_VECTOR __interrupt void RF13M_ISR(void) { } //#pragma CODE_SECTION(WDT_ISR, ".fram_driver_code") //comment this line for using ROM's WDT ISR, uncomment next one #pragma CODE_SECTION(WDT_ISR, ".wdt_rom_isr") //comment this line for creating a custom WDT ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = WDT_VECTOR __interrupt void WDT_ISR(void) { } //#pragma CODE_SECTION(TimerA1_ISR, ".fram_driver_code") //comment this line for using ROM's Timer_A1 ISR, uncomment next one #pragma CODE_SECTION(TimerA1_ISR, ".timer_a1_rom_isr") //comment this line for creating a custom WDT ISR TimerA1 that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = TIMER0_A1_VECTOR __interrupt void TimerA1_ISR(void) { } //#pragma CODE_SECTION(TimerA0_ISR, ".fram_driver_code") //comment this line for using ROM's Timer_A0 ISR, uncomment next one #pragma CODE_SECTION(TimerA0_ISR, ".timer_a0_rom_isr") //comment this line for creating a custom WDT ISR Timer_A0 that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = TIMER0_A0_VECTOR __interrupt void TimerA0_ISR(void) { } //#pragma CODE_SECTION(UNMI_ISR, ".fram_driver_code") //comment this line for using ROM's UNMI ISR, uncomment next one #pragma CODE_SECTION(UNMI_ISR, ".unmi_rom_isr") //comment this line for creating a custom WDT UNMI ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = UNMI_VECTOR __interrupt void UNMI_ISR(void) { } //#pragma CODE_SECTION(SysNMI_ISR, ".fram_driver_code") //comment this line for using ROM's SYSNMI ISR, uncomment next one #pragma CODE_SECTION(SysNMI_ISR, ".sysnmi_rom_isr") //comment this line for creating a custom WDT SYSNMI ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = SYSNMI_VECTOR __interrupt void SysNMI_ISR(void) { } #pragma RETAIN (Reset_ISR); //#pragma CODE_SECTION(Reset_ISR, ".fram_driver_code") //comment this line for using ROM's RESET ISR, uncomment next one #pragma CODE_SECTION(Reset_ISR, ".reset_rom_isr") //comment this line for creating a custom WDT RESET ISR that will exist in FRAM, bypassing ROM's, uncomment previous #pragma vector = RESET_VECTOR extern __interrupt void Reset_ISR(void) { }