Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by RSABear

  1. Follow my sample code posted here and you will fix the problem: http://forum.sourceboost.com/index.php?showtopic=4531
  2. Reynard, thank you so much for the help. There is a single instruction missing in the EE_Get_Int(). The fix is, the "eecon1.CFGS = false;": Kind Regards Bernard
  3. Yes, the code is old, i have not used/updated it for while. I have swopped bits 1 and 2 in the following definitions. #define state_3 0b00001100 // State 3 (0x0C) - SSPSTAT bits: D_A = 0, S = 1, R_W = 1, BF = 0 #define state_4 0b00101100 // State 4 (0x2C) - SSPSTAT bits: D_A = 1, S = 1, R_W = 1, BF = 0 the bug results in a State of 0x0A and 0x2C, which will not allow you to read data from the slave correctly. > My apologies, I did not update the version and date in the source file which I uploaded (after I made the corrections).
  4. I now have the I2C_Slave working on the 16F88. See the downloadable demo code, processor config is straight forward. and review this post: I2C Bug Report
  5. Hi all - I found a bug in my I2C Slave demo code. State 3 & 4 are incorrectly defined. The following lines of code corrects the bug: #define SSPSTAT_BIT_MASK 0b00101101 // Mask for I2C status bits // bit 0 BF: Buffer Full Status bit // bit 2 R/W: Read/Write bit Information (I2C mode only) // bit 3 S: START bit // bit 5 D/A: Data/Address bit (I2C mode only) // AN734a DS00734A-page 10 - Definitions for Older Devices //--------------------------------------------------------------------- // The I2C code below checks for 5 states: // S 1 = Start condition occuurred last // R/W 0 = Master writing data to Slave 1 = Master reading from Slave // D/A 0 = Last Byte was an Address 1 = Last Byte was Data // BF 0 = Buffer Empty 1 = Buffer Full //--------------------------------------------------------------------- // The following table on AN734a DS00734A-page 10 // State 1: I2C write operation, last byte was an address byte. // SSPSTAT bits: S = 1, D_A = 0, R_W = 0, BF = 1 // State 2: I2C write operation, last byte was a data byte. // SSPSTAT bits: S = 1, D_A = 1, R_W = 0, BF = 1 // State 3: I2C read operation, last byte was an address byte. // SSPSTAT bits: S = 1, D_A = 0, R_W = 1, BF = 0 // State 4: I2C read operation, last byte was a data byte. // SSPSTAT bits: S = 1, D_A = 1, R_W = 1, BF = 0 // State 5: Slave I2C logic reset by NACK from master. // SSPSTAT bits: S = 1, D_A = 1, R_W = 0, BF = 0 //---------------------------------------------------------------------- // 76543210 // XXDXSRXB #define state_1 0b00001001 // State 1 (0x09) - SSPSTAT bits: D_A = 0, S = 1, R_W = 0, BF = 1 #define state_2 0b00101001 // State 2 (0x29) - SSPSTAT bits: D_A = 1, S = 1, R_W = 0, BF = 1 #define state_3 0b00001100 // State 3 (0x0C) - SSPSTAT bits: D_A = 0, S = 1, R_W = 1, BF = 0 #define state_4 0b00101100 // State 4 (0x2C) - SSPSTAT bits: D_A = 1, S = 1, R_W = 1, BF = 0 #define state_5 0b00101000 // State 5 (0x28) - SSPSTAT bits: D_A = 1, S = 1, R_W = 0, BF = 0 Code_877A_1.c
  6. Hi all, Bit of an old thread, but... Have you ever made this Slave code work? I am busy porting my 16F887 Slave code to 16F88 and scanning the forums for any issues... Please - let me know.
  7. Before I post this question on the dreaded Microchip Forum, I would like to see if somebody else ran into this problem. For the first time I would like to build a project in Microchip MPLAB V8.36 which has include files and library files in different directories. I have added the –I and –obj switches to the BoostC compiler. For the source files located outside the project directory, one needs to uncheck the “Inherit Global Settings” checkbox under the Build Options and hit the apply button, but there seems to be a bug there as the settings does not get saved by MPLAB and the Apply Button plays up - you need to check and uncheck the button to enable the Apply Button. Is there a way to configure the setting somewhere else? OR How do you setup a project for source files in multiple directories to compile successfully, it seem to be the root of the problem, rather than the above. AND Editing the project.mcp file does not work either, the sub directories are ignored.
  8. It is going to be a FAT help, it will do the trick. Thank you.
  9. I have been using 24FC512 EEPROMS. Now I need much more memory space. Can anyone help or has anyone written C code for a SD Memory card I can use to get me started?
  10. Excellent! I somehow missed it in the header file....
  11. I would like to software reset/reboot the 18F4550. Can someone point me in the right direction? For the 16F chips I used the following code:
  12. Yes it does. Receive and Transmit. I build the 3 channel IR transmitter form sixca and the receiver from code on the EDABOARD website. There are 100s of sites with schematics, code and information.
  13. Hi Ian, I constructed my board last weekend and tested the hardware with the Microchip Bootloader & MCHPFSUSB Demo code. The hardware works fine for the MCHPFSUSB demo. I have not tested the Micochip CDC firmware on the board. I have compile the PIC Pack Rc1 demo however, it does not enumerate on the USB Bus (yet). The RS232 portion works, I get the messages and can input the a command. I don't attach to the USB - and when I de-attach I get to: serial_print_str(" don't own it! "); Can you recommend a USB Sniffer to use in order so see if data is flowing IN/OUT and help to start the debug process? I also assume that when we enumerate we are going to use the CDC driver form (which will then create a standard serial port): x:\MCHPFSUSB\fw\CDC\inf\win2k_winxp I attach my schematic and board for reference and for other users who would like to get started with USB. Anyway - it is exciting stuff, the posibilities are great. Let's see how we go forward.
  14. I have done so. I also included the schematic of the USB Test Board I have build. RSABear
  15. Ian do you need help? Even if it is just testing etc... I have been fighting with the MCHPFSUSB C18 USB code for a while. Would really like to get CDC part working for my projects.
  16. Don't worrie it is called a "learning curve" and within a few weeks you will have the hang of and will be thinking and writing in BoostC as if it was made for you. Guess what? - You'll never go back to where yo come from...
  17. You will see a lot of requests for this - look at the USB topics in the forum, especially porting the Microchip C18 firmware to BoostC.
  18. Firstly - I hate all the PIC16F877s in the world - consider the PIC16F887 device. Sorry it is a personal thing. I tried to copy and paste all the relevant lines of code from my project. I stay away from floating point maths, and in this example I convert the ADC value to an ASCII string for output to a data logger. It will not compile, you have to adapt it for your hardware and I do not guarantee accuracy - the example should get you going in good time. I hope it helps you as it took me a couple of weeks to figure the plan on this one. #include <system.h> #include <adc.h> // _PIC16F877A // Set the 16F877A device configuration bits #pragma DATA _CONFIG, _CPD_OFF & _DEBUG_ON & _PWRTE_ON & _LVP_OFF & _BODEN_ON & _PWRTE_ON & _WDT_OFF & _XT_OSC #pragma CLOCK_FREQ 4000000 // 4Mhz Clock // Calculate the conversion factor in this type of programme // Input range from voltage divider 0 - 5.0V : ADC Input range 0 - 5V Max // Voltage - 5.0V max on the ADC might be differ in your circuit - meassure it with a DVM // Max level at ( 5.0/5.0 * 100 ) = 100% // Digital value = 1024 * 100% = 1024 // e.g. for 33V PSU Output (33/1024) = 0.032226562V = 32.2mV Resolution // Conversion factor = 0.03 * 1000000 = 32226 // Volt Value - For calibration #define volt_conversion_factor 32226 #define buff_len 10 // Create a buffer to store the ASCII value of the ADC Value char volts_buffer[buff_len]; // 10-Digits + ZERO at the end of the string unsigned int int_volt_value; unsigned long lng_voltage; // Create a pointer to reference the ASCII values by char *str_voltage; //////////////////////////////////////////////////////////// // PIC Microchip 16F77A – ADC hardware init code //////////////////////////////////////////////////////////// void adc_init(void){ // _PIC16F877A volatile bit adc_on @ ADCON0 . ADON; //AC activate flag // The PCFG bit can setup AN0/1/3 for Analogue Input and keep the the other PINs Digital // Set-up for channel 1 - Voltage // A/D Conversion Clock Select bits clear_bit(adcon1, ADCS2); // 0 - Select Tad = 32 * Tosc @ 4.0Mhz set_bit(adcon0, ADCS1); // 1 - Select Tad = 32 * Tosc @ 4.0Mhz clear_bit(adcon0, ADCS0); // 0 - Select Tad = 32 * Tosc @ 4.0Mhz clear_bit(adcon0, CHS2); // 0 - Channel 1 AN3 PIN 3 clear_bit(adcon0, CHS1); // 0 - Channel 1 AN3 PIN 3 set_bit(adcon0, CHS0); // 1 - Channel 1 AN3 PIN 3 set_bit(adcon1, ADFM); // AD result needs to be right justified // 0100 AN0, AN1 & AN3 Input Vss & Vdd as reference voltages clear_bit(adcon1, PCFG3); set_bit(adcon1, PCFG2); clear_bit(adcon1, PCFG1); clear_bit(adcon1, PCFG0); adc_on = 1; // Activate AD module } // The C Entry Code void main() { adc_init(); // Setup and configure the PIC ADC // PIC Setup // Set the 16F877A device up cvrcon = CLEAR; cmcon = CLEAR; ccp1con = CLEAR; ccp2con = CLEAR; option_reg = 0B00000010; // Set RB0/INT on falling edge, set TMR0 pre-scaler #endif trisd = CLEAR; portd = 0x00; str_voltage = &volts_buffer[0]; // Get the address of the string buffers into the pointers while( TRUE ) { int_volt_value = 0x0000; // Clear the ADC result values lng_voltage = 0x0000; // Clear the calculated result values ltoa( lng_voltage, str_voltage, 10 ); // Initialise the buffer for the display value // Read the Voltage // Set-up for Channel 1 - Voltage // _PIC16F877A // Set the 16F877A ADC Channel Selection clear_bit(adcon0, CHS2); // 0 - Channel 1 AN1 PIN 3 clear_bit(adcon0, CHS1); // 0 - Channel 1 AN1 PIN 3 set_bit(adcon0, CHS0); // 1 - Channel 1 AN1 PIN 3 delay_ms(1); // You need a short delay, in my application it can be 1ms adc_go = 1; // Start the conversion while (adc_go); // Wait until it is done MAKESHORT( int_volt_value, adresl, adresh ); // Combine 10bit ADC value into result lng_voltage = (int_volt_value * volt_conversion_factor); // Voltage conversion from ADC ltoa( lng_voltage, str_voltage, 10 ); // Convert the buffer to ascii and your result is a string with no decimal point. Thank you. } // End While Loop } // End main()
  19. Thanks for the great piece of information – I so much needed some good news today. Please help us Geoff... I think we should play by the rules - Microchip's rules, it is the correct thing to do. Microchip should be asked the following question - What is the main objective of their sales channel, to sell processors or protect code? If the answer is to increase sales then we have a means of getting more USB PICs sold. Engineers and developers will have a USB library on BoostC to deploy on these processors. I suggest we go the route of their 18F Microprocessor Product Support Staff to assists us to turn the decision into our (SourceBoost) favor. What sort of pull does Hi-Tech have with Microchip to publish a port of the Microchip demo code? (or else Microchip does not know this) More 18F sales = USB CDC Firmware in public domain I assume it is clear that there is a demand for USB in the PIC C programming community? Have a look at the views on this thread. Does anybody have strong contacts in Microchip to help us to help them sell more 18F processors? Once we have the above in place, we can light a candle on both ends for Pavel & Dave…
  20. Each have its benefits - I use both. Mainly MPLAB for larger projects and Boost IDE for quick and simple projects. Boost IDE is simple and easy and is great for teaching students the basics of PIC programming - without much complexity and fuzz. Also have a look at the Plug-in's for BoostC. Try both and decide for yourself.
  21. I prefer to have the USB CDC in the firmware of the PIC. The problem is that my project (Energy Consumption Meter) is currently in the PIC18F4550 by means of Microchip C18 (and it works). The problem is to get it from C18 to BoostC in such a way that it still works...
  22. USB CDC is the way to go. Porting the Microchip C18 code to BoostC is not an easy task, I have been studying the code part time and can’t commit time as I am pretty tied-up at work with on a project. One would ultimately try and retain the code developed by Microchip in the CDC systems directory and not modify this code except for the typedefs.h file and adding specific definitions for the BoostC compiler. The porting problem appears to be largely focused around the differences between the way data structures, unions and especially bit data is handled by the different compilers as well as the placing the code in segments by the linker. I do not have the detailed in-depth know how on C to easily port the code – thus progress is very slow and painful.
  23. It is very simple - the schematic is posted here -> PIC16F627 RS232 Schematic I don't use the MAX233 chip anymore the DS275 is smaller/cheaper and does the same function.
  24. I have received my PIC18F4550's. I have recompiled the Microchip MCHPFSUSB Demo & CDC with C18 and it is working as described in the documentation. While searching for information on the 18F4450 problem, I noted that Hi-Tech has a port of the MCHPFSUSB CDC posted on their website as well. I have not ported many applications - but can see a few challanges here. I suggest a new thread in the "BoostC porting source code" forum to address the matter.
  • Create New...