This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Setting SYSCON register before EINIT.

Hello, I am trying to initialise the CAN interface on a C164 - I need to set the XPEN bit, and clear the CAN1DIS bit in the SYSCON register.

However, I am using C, and thus C_STARTUP_CODE is loaded into RAM, which contains the EINIT instruction (which locks down access to SYSCON). Therefore, EINIT has already been executed by the time my main() starts, and so I cannot access this register.

I'm having trouble interpreting the machine code on the reset vectors too, so I can't just put a JumpToHere, JumpToThere, sequence in.

Any help would be much appreciated.

Parents
  • Hi there Mike, thanks for your reply.

    Nothing, now that I know which file to get! I've been thrown onto this project with the scantest (read: nothing) of documentation and it's a nightmare. :)

    It seems though, that the label given to the SYSCON bit I am interested in has different names in my user-manual (XPEN) and in Start167.A66 (_XRAMEN). Is this an issue?

    It also seems from some preliminary testing, that setting this bit shuts down my use of RS-232 in testing (I'm using printf()'s to write register values to screen).. does this seem likely?

    Once again, thanks a lot for your help.

Reply
  • Hi there Mike, thanks for your reply.

    Nothing, now that I know which file to get! I've been thrown onto this project with the scantest (read: nothing) of documentation and it's a nightmare. :)

    It seems though, that the label given to the SYSCON bit I am interested in has different names in my user-manual (XPEN) and in Start167.A66 (_XRAMEN). Is this an issue?

    It also seems from some preliminary testing, that setting this bit shuts down my use of RS-232 in testing (I'm using printf()'s to write register values to screen).. does this seem likely?

    Once again, thanks a lot for your help.

Children
  • Sorry, cancel that last comment re: RS232.

  • During build-time, it seems like the only file the build-process needs is one called C167S.LIB, and putting deliberate errors into the START*.A66 files does nothing.

    When I open C167S.LIB, I can see the text "C_STARTUP_CODE", so I assume I have to change the source of this file, and then compile it (?) again.

    The EINIT command it definitely contained within this C_STARTUP stuff, as I can see from the .M66 file. Perhaps the settings for SYSCON are too?

  • It seems though, that the label given to the SYSCON bit I am interested in has different names in my user-manual (XPEN) and in Start167.A66 (_XRAMEN). Is this an issue?

    It's hard to say. START167.A66 from my Keil distribution doesn't have the label _XRAMEN. But it's not necessarily a problem. Anyway, just make sure that it's bit number 2 (SYSCON.2). The reason why they could call it _XRAMEN is that on some C16x chips XRAM is the only X-peripheral, if my memory serves me.

    It also seems from some preliminary testing, that setting this bit shuts down my use of RS-232 in testing

    I've never dealt with a C164, so I really don't know. Could it be that in your microcontroller CAN pins are multiplexed with UART pins, so it can't be both at the same time? Or maybe it's something more subtle.

    - mike

  • When I open C167S.LIB, I can see the text "C_STARTUP_CODE", so I assume I have to change the source of this file, and then compile it (?) again.

    If the file START167.A66 is not included in your project, then the default version of it is pulled out of C167S.LIB. Sometimes that will do.
    But normally you need to copy START167.A66 to your program folder and include it in your project. Then customize it to your liking. It will override the code in C167S.LIB.

    - mike

  • By the way, it's all in the manuals:

    http://www.keil.com/support/man/docs/c166/c166_ap_startupcode.htm

    There should be copies of the manuals in PDF format in your Keil distribution.

    - mike

  • Mike, you're a king among men. SYSCON now reads 0x04, which is great.

    My CAN messages still aren't being sent or received, but at least I'm one step further.

    Many thanks,

    Chris.